Problem description:
Save the json parsing result in nsdictionary:
[Plain]
{
"StatusCode": "200 ",
"Body ":[
{
"Status": "success ",
"Remarks": null
}
],
"Data ":[
"Abcd ":[
{
"Category": "",
"Title": "B ",
"Id": "24"
},
{
"Category": "c ",
"Title": "crd ",
"Id": "65"
},
{
"Category": "ds ",
"Title": "sd ",
"Id": "18"
}
]
},
{
"Efgh ":[
{
"Category": "ds ",
"Title": "sd ",
"Id": "18"
},
{
"Category": "sd ",
"Title": "sd ",
"Id": "1"
}
]
},
{
"Ijkl ":[
{
"Category": "ds ",
"Title": "sd ",
"Id": "18"
},
{
"Category": "sd ",
"Title": "sd ",
"Id": "1"
}
]
}
]
}
{
"StatusCode": "200 ",
"Body ":[
{
"Status": "success ",
"Remarks": null
}
],
"Data ":[
"Abcd ":[
{
"Category": "",
"Title": "B ",
"Id": "24"
},
{
"Category": "c ",
"Title": "crd ",
"Id": "65"
},
{
"Category": "ds ",
"Title": "sd ",
"Id": "18"
}
]
},
{
"Efgh ":[
{
"Category": "ds ",
"Title": "sd ",
"Id": "18"
},
{
"Category": "sd ",
"Title": "sd ",
"Id": "1"
}
]
},
{
"Ijkl ":[
{
"Category": "ds ",
"Title": "sd ",
"Id": "18"
},
{
"Category": "sd ",
"Title": "sd ",
"Id": "1"
}
]
}
]
}
Data with the keyword @ data can be saved in the array:
[Plain]
NSMutableArray * getdata = [[NSMutableArray alloc] init];
Getcat = [results objectForKey: @ "data"];
NSMutableArray * getdata = [[NSMutableArray alloc] init];
Getcat = [results objectForKey: @ "data"];
The following describes how to set values (category, title, id) in the first index ). For example, 'abc '?
Thank you.
Solution:
Getdata should contain three NSDictionary values:
[Plain]
{
"Category": "",
"Title": "B ",
"Id": "24"
},
{
"Category": "c ",
"Title": "crd ",
"Id": "65"
},
{
"Category": "ds ",
"Title": "sd ",
"Id": "18"
}
{
"Category": "",
"Title": "B ",
"Id": "24"
},
{
"Category": "c ",
"Title": "crd ",
"Id": "65"
},
{
"Category": "ds ",
"Title": "sd ",
"Id": "18"
}
You need to set values in the first index
[Plain]
NSDictionary * firstDic = [getdata objectAtIndex: 0];
[FirstDic setValue: @ "new category" forKey: @ "category"];
[FirstDic setValue: @ "new title" forKey: @ "title"];
[FirstDic setValue: @ "new id" forKey: @ "id"];
NSDictionary * firstDic = [getdata objectAtIndex: 0];
[FirstDic setValue: @ "new category" forKey: @ "category"];
[FirstDic setValue: @ "new title" forKey: @ "title"];
[FirstDic setValue: @ "new id" forKey: @ "id"];