Skip navigation.
 
mlRE: checking if a string is with in a different string
FROM : Oliver Donald
DATE : Wed Apr 13 15:34:09 2005

The method you want isn't immediately obvious by name, but its in the
'Substrings' section of the NSString docs. You want to use one of these...

[myString rangeOfString:subString];
[myString rangeOfString:subString options:];
[myString rangeOfString:subString options: range:];

Returns an NSRange, with a location of NSNotFound if 'subString' isn't a
substring of 'myString'.

Hope that helped!

-----Original Message-----
From: Tom Hancocks [mailto:<email_removed>]
Sent: 13 April 2005 14:23
To: <email_removed>
Subject: checking if a string is with in a different string


Sorry thats worded badly but i couldn't think of how else to put it,
anyways. I have recently moved from RB, as stated in previous posts of
mine, and i'm still trying to get to grips with it all, but i must say
i am getting there, thankfully.

I'm creating a search function for my program, and in RB i would of
used the InStr function to check if a string occured in side another
string for example

searchString        :World
string            :Hello World
Found            :YES

like i said i would of done

if instr(String,SearchString)>0 Then
   //It was found
else
   //not found
end if

In Obj-C i have tried to do this:

if ([string compare:searchString] == NSNotFound){
   //Not Found
}else{
   //Found
}

but it has not worked, could anyone help me out and tell where i'm
going wrong?

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (<email_removed>)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>

This email sent to <email_removed>


DISCLAIMER: The information contained in this e-mail is confidential and may
be privileged. It is intended for the addressee only. If you are not the
intended recipient, please delete this e-mail immediately. The contents of
this email must not be disclosed or copied without the sender's consent. We
cannot accept any responsibility for viruses, so please scan all
attachments. The statements and opinions expressed in this message are those
of the author and do not necessarily reflect those of the company. The
company does not take any responsibility for the views of the author.

Related mailsAuthorDate
mlchecking if a string is with in a different string Tom Hancocks Apr 13, 15:22
mlRe: checking if a string is with in a different string j o a r Apr 13, 15:32
mlRE: checking if a string is with in a different string Oliver Donald Apr 13, 15:34