1

mainstr is my string contains:

 123;456;23;ns@234;343;3;ner@975;013;742;av@ 

arr is my array name.

each location of array contains some string like (should be separated by @)

arr[0]=[123;456;23;ns];

arr[1]=[234;343;3;ner];

I want to separate each element of arr[0] into separate array (they should be separated based on occurrence of ; )..

for example

newarray[0]=[123] 

newarray[1]=[23]

newarray[2]=[45]

newarray[3]=[ns]

how should I do this ?

1

1 Answer 1

1

You can use the firstly

NSArray *stringArray = [mainstr componentsSeparatedByString:@"@"];

then you can use

NSArray *arr0 = [[stringArray objectAtIndex:0] componentsSeparatedByString:@";"];
and so on...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.