Iphone SDk inString Function

Posted by Skeep on Stack Overflow See other posts from Stack Overflow or by Skeep
Published on 2010-04-28T11:25:47Z Indexed on 2010/04/28 16:43 UTC
Read the original article Hit count: 344

Filed under:
|
|

Hi All,

Im trying to write a method that will pull out the ID from a URI String. My code below seems inefficient, what would be a better way of finding the id string?

NSString *aID = [[[NSString alloc] initWithString:@"http://www.example.com/id368907840?mt=8&uo=4"] autorelease];
NSArray *arrStr = [aID componentsSeparatedByString:@"/id"];
aID = [arrStr objectAtIndex:1];
arrStr = [aID componentsSeparatedByString:@"?mt="];
aID = [arrStr objectAtIndex:0];

The above leaves me with the NSString = 368907840

© Stack Overflow or respective owner

Related posts about iphone-sdk

Related posts about iphone