Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you split NSString into component parts?

In Xcode, if I have an NSString containing a number, ie @"12345", how do I split it into an array representing component parts, ie "1", "2", "3", "4", "5"... There is a componentsSeparatedByString on the NSString object, but in this case there is no delimiter...

like image 515
Graham Whitehouse Avatar asked Oct 15 '10 12:10

Graham Whitehouse


1 Answers

There is a ready member function of NSString for doing that:

NSString* foo = @"safgafsfhsdhdfs/gfdgdsgsdg/gdfsgsdgsd";
NSArray* stringComponents = [foo componentsSeparatedByString:@"/"];
like image 50
VLegakis Avatar answered Sep 28 '22 00:09

VLegakis