0

I have a string retrieving from sqlite

({ 
    studentId = SUE1291ST;
    studentName = "Student123Sdfw"; 
  }, 
  { 
    studentId = SUE13291ST;
    studentName = "name123Sdfw";
 })

how to convert to NSMutableArray and to get NSDictionary.... ?

3
  • stackoverflow.com/questions/13834390/… Commented Sep 13, 2013 at 7:28
  • 1
    google for "json parse ios" and u will get alot of help. google.com.pk/#q=json+parser+ios&spell=1 Commented Sep 13, 2013 at 7:28
  • 1
    It seems that you used the description method to convert an NSArray into a string and store that into the SQLite database. There is no reliable way to reconstruct the array/dictionary from the description string (see stackoverflow.com/a/16783704/1187415 for an unreliable method). You should store the dictionary in a different way, e.g. in JSON format. Commented Sep 13, 2013 at 7:54

2 Answers 2

0

If the format is json (as your tags suggest) the easiest way is to use NSJSONSerialization

Using

+ (id)JSONObjectWithData:(NSData *)data options:(NSJSONReadingOptions)opt error:(NSError **)error

Will get you a foundation class object returned (NSArray, NSDictionary, depending on the json data)

Sign up to request clarification or add additional context in comments.

2 Comments

it is not a json.it is a string value from sqlite db
@user2775424 then why do you use the json tag? Google "NSString parsing", it will tell you everything you need.
0
u want dict values from array..so

 dataArray =[NSMutableArray array];
    NSMutableDictionary *dic =[[NSMutableDictionary alloc]init];
    [dic setObject:@"SUE1291ST" forKey:@"studentId"];
    [dic setObject:@"Student123Sdfw" forKey:@"studentName"];

    [dataArray addObject:dic];

     dic =[[NSMutableDictionary alloc]init];
    [dic setObject:@"SUE13291ST" forKey:@"studentId"];
    [dic setObject:@"name123Sdfw" forKey:@"studentName"];

    [dataArray addObject:dic];

    NSLog(@"dataArray:%@",dataArray);

    for (NSDictionary *dic in dataArray) {

        NSLog(@"DICTIONARY IS:%@",dic);
    }

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.