2

Here is my code to get a json response string

I am getting this string by using this method

NSDictionary *selector = [json valueForKey: @"Title"];
NSMutableArray *dictArray = [[NSMutableArray alloc] initWithObjects: selector,nil];
str1=[[dictArray objectAtIndex:i] valueForKey:@"CompanyName"];

To print the "str1"

I am getting

(
    "[email protected]"
),
    (
    "[email protected]",
    "[email protected]"
),
    (
    "[email protected]"
),
    (
    "[email protected]"
),
    (
    "[email protected]"
),
    (
    "[email protected]"
),
    (
    "[email protected]"
),
    (
    "[email protected]"
)

)

I am trying to store in array by using "," operator

like this way

NSArray *SplitStringArray = [str1 componentsSeparatedByString:@", "];

but I didn't split the string into array of elements

Could please any one help me?

2

2 Answers 2

1
    NSDictionary *selector = [json valueForKey: @"Title"];

    NSMutableArray *dictArray = [[NSMutableArray alloc] initWithObjects: selector,nil];

    NSMutableArray *str1Array=[[dictArray objectAtIndex:i] valueForKey:@"CompanyName"];


        //note this line
    NSMutableArray *SplitStringArray =[[NSMutableArray alloc]init];

    for (id eachArray in str1Array) {


        if ([eachArray count]>0) {


            for (int i = 0; i<[eachArray count]; i++) {

                NSString *emailid=[NSString stringWithFormat:@"%@",[eachArray objectAtIndex:i]];

                [SplitStringArray addObject:emailid];


            }

        }

    }

    NSLog(@"SplitStringArray : %@",SplitStringArray);
Sign up to request clarification or add additional context in comments.

5 Comments

update code and note that NSMutableArray *SplitStringArray =[[NSMutableArray alloc]init];
previously i initialise the array]
thanks dude and have a great learning practices...for quick ref join here chat.stackoverflow.com/rooms/682/iphone-ipad
hi friend i got the above solutions but i didn't get the solution for
hi friend i got the above solutions but i didn't get the solution for { Description = "Mic";EndDate = "/Date(1275832800000+0000)/";FriendlyName = TB3259;Id = 4;Location = "Building N-4105";Speakers =({Company = HP;Email = "[email protected]"; Name = "Jane Doe";Title = "Vice President";});StartDate = "/Date(1275829200000+0000)/"; },here is my json response in that i got selectors data but whenever i am trying get the friendly name i didn't get that one.In str1array takes the values whenever i append the table cell.The execution quit.what will i do please help me
1
NSMutableArray *SplitStringArray = [[NSMutableArray alloc]init]; 
[SplitStringArray setArray:[str1 componentsSeparatedByString:@","]];

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.