Compare part of a string in Obj C

Joined
Jan 4, 2011
Messages
5
Reaction score
0
Points
1
Location
Canada
Your Mac's Specs
Macbook Pro 13" 2.44ghz 4GB 250GB
I am trying to compare multiple strings. I have tried isEqual and caseSensitiveCompare but they only work if they match completely. I would like to compare a string and the start of another string.

ex string1 = @"hello"
string2 = @"he"

I would like compare these and get a positive result.
 
Joined
Jun 25, 2005
Messages
3,231
Reaction score
112
Points
63
Location
On the road
Your Mac's Specs
2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
Looks like the method
Code:
commonPrefixWithString:options:
could be your solution. I found that in the NSString class documentation.
 
OP
T
Joined
Jan 4, 2011
Messages
5
Reaction score
0
Points
1
Location
Canada
Your Mac's Specs
Macbook Pro 13" 2.44ghz 4GB 250GB
That worked. Thanks.
I used prefixWithString. I am new to programming and just getting used to finding the right methods in the documentation. I appreciate the help. Thanks again.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top