开发者

Obj-C / iPhone: NSArray question

开发者 https://www.devze.com 2023-01-09 16:20 出处:网络
I have an array that looks like this when printed via NSLog: { response = \"Valid\"; updates = ( { string = \"test\";

I have an array that looks like this when printed via NSLog:

{
response = "Valid";
updates = (
         {
         string = "test";
         integer = 3493;
         },
         {
         string = "test2";
         integer = 55454;
         }
       开发者_C百科  );
start-index = 0;

My question is how I can loop through through the "updates" array so that I may print the values for each "string" respectively.

Should be an easy "for" loop or something?

Dave


Assuming you NSLogged data has a type of NSDictionary with name data.

NSArray *updates = [data objectForKey:@"updates"];
for (NSDictionary *update in updates) {
    NSLog(@"Update: %@ - %@", [update objectForKey:@"string"], [update objectForKey:@"integer"]);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消