objective c - using NSPredicate on nested dictionary/array -


i'm trying use nested data structure , nspredicate filter data.

i have plist file this:

<!doctype plist public "-//apple//dtd plist 1.0//en" "http://www.apple.com/dtds/propertylist-1.0.dtd"> <plist version="1.0"> <dict>         <key>images-ipad</key>         <array>                 <dict>                         <key>categories</key>                         <array>                                 <string>standard</string>                         </array>                         <key>name</key>                         <string>default</string>                         <key>plist</key>                         <string>cardsheet.plist</string>                         <key>png</key>                         <string>cardsheet.png</string>                 </dict>                 <dict>                         <key>categories</key>                         <array>                                 <string>standard</string>                         </array>                         <key>name</key>                         <string>optional</string>                         <key>plist</key>                         <string>cardsheet.plist</string>                         <key>png</key>                         <string>cardsheet.png</string>                 </dict>                 <dict>                         <key>categories</key>                         <array>                                 <string>christmas</string>                                 <string>holiday</string>                                 <string>standard</string>                         </array>                         <key>name</key>                         <string>christmas</string>                         <key>plist</key>                         <string>cardsheet.plist</string>                         <key>png</key>                         <string>cardsheet.png</string>                 </dict>         </array> </dict> </plist> 

which load nsdictionary via dictionwithcontentsoffile.

i want elements of array images-ipad in category 'standard' via nspredicate. think possible, i've not been able accomplish it, , docs don't seem cover nested data structures.

so, i've tried this:

nspredicate *getcat = [nspredicate predicatewithformat:@"any images-ipad.categories == 'holiday'"]; nsarray *res = [[dict objectforkey:@"images-ipad"] filteredarrayusingpredicate:getcat]; 

but not return elements, brings me stackoverflow. in advance.

since you're filtering result of [dict objectforkey:@"images-ipad"], shouldn't include string in key path of predicate, it's equivalent looking images-ipad.images-ipad.categories, doesn't exist.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -