• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: checking if a string is with in a different string
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: checking if a string is with in a different string


  • Subject: Re: checking if a string is with in a different string
  • From: j o a r <email@hidden>
  • Date: Wed, 13 Apr 2005 15:32:29 +0200


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?

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >checking if a string is with in a different string (From: Tom Hancocks <email@hidden>)

  • Prev by Date: checking if a string is with in a different string
  • Next by Date: RE: checking if a string is with in a different string
  • Previous by thread: checking if a string is with in a different string
  • Next by thread: RE: checking if a string is with in a different string
  • Index(es):
    • Date
    • Thread