tags:

views:

26

answers:

1

How can I traverse in the plist to get the value number?

My plist looks like this:

Arrays
  Array
    Dictionary
       Number
       Number
  Array
    ...

So in code, I've already started something:

NSString *imagePlist = [[NSBundle mainBundle] pathForResource:@"Imageinfo" ofType:@"plist"];    
NSArray *imageArray = [[NSArray alloc] initWithContentsOfFile:imagePlist]; 

I don't know what's next??? Pls advise. Thanks

A: 

Now that you have an NSArray... Look for objectAtIndex: or use: for (NSArray *secondLevelArray in imageArray) { ...do something with secondLevelArray... }

And for NSDictionary, objectForKey: or for (id key in dict) {...} or whatever you want.

For NSNumber: [number intValue] or float or double or whatever you need.

jtbandes
ok... I've forgot this.. what if inside the second level array are dictionaries? how u should traverse into it? still objectForKey: ?
devb0yax
You could say `for (NSDictionary *dict in secondLevelArray) {...}`
jtbandes
yes..got it already.. thanks... btw, i've just seen you in iphonedev irc channel..thanks anyway. :)
devb0yax