Illep
Illep

Reputation: 16841

Split a String and save it

I have a String in the following format;

NSString *string1 = @"123 ki net 235 lk";

I need to format the above String and save it in 2 Strings;

NSString *Start, *end;

These strings should have the out put

String = 123 ki

end = 235 lk

Basically, i want to do is, to split the string so the final output will be 123 ki and 235 lk. How can i do this ?

Upvotes: 0

Views: 68

Answers (1)

saturngod
saturngod

Reputation: 24967

You can use componentsSeparatedByString

Example:

NSArray* split  = [string1 componentsSeparatedByString: @" net "];

Start = [split objectAtIndex:0];
end = [split objectAtIndex:[split count]-1];

Upvotes: 1

Related Questions