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

(
    "hello@developer.com"
),
    (
    "hello@developer.com",
    "helloworld@microsoft.com"
),
    (
    "hello@developer.com"
),
    (
    "hello@developer.com"
),
    (
    "hello@developer.com"
),
    (
    "hello@developer.com"
),
    (
    "hello@developer.com"
),
    (
    "hello@developer.com"
)

)

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?

dasdom
  • 13,975
  • 2
  • 47
  • 58
kumar
  • 453
  • 1
  • 5
  • 26

2 Answers2

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);
  • update code and note that NSMutableArray *SplitStringArray =[[NSMutableArray alloc]init]; – Vijay-Apple-Dev.blogspot.com May 23 '12 at 12:11
  • previously i initialise the array] – kumar May 23 '12 at 12:34
  • thanks dude and have a great learning practices...for quick ref join here http://chat.stackoverflow.com/rooms/682/iphone-ipad – Vijay-Apple-Dev.blogspot.com May 23 '12 at 13:16
  • hi friend i got the above solutions but i didn't get the solution for – kumar May 24 '12 at 06:53
  • 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 = "janedoe@hp.com"; 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 – kumar May 24 '12 at 06:59
1
NSMutableArray *SplitStringArray = [[NSMutableArray alloc]init]; 
[SplitStringArray setArray:[str1 componentsSeparatedByString:@","]];
cutebug
  • 475
  • 4
  • 10