FROM : j o a r
DATE : Wed Apr 13 15:32:29 2005
NSRange foundRange = [sourceStr rangeOfString: searchStr];
if (foundRange.location != NSNotFound)
{
// Found
}
else
{
// Not found
}
j o a r
On 2005-04-13, at 15.22, Tom Hancocks wrote:
> 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?
DATE : Wed Apr 13 15:32:29 2005
NSRange foundRange = [sourceStr rangeOfString: searchStr];
if (foundRange.location != NSNotFound)
{
// Found
}
else
{
// Not found
}
j o a r
On 2005-04-13, at 15.22, Tom Hancocks wrote:
> 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?
| Related mails | Author | Date |
|---|---|---|
| Tom Hancocks | Apr 13, 15:22 | |
| j o a r | Apr 13, 15:32 | |
| Oliver Donald | Apr 13, 15:34 |






Cocoa mail archive

