ios - Getting data from API, need to filter results -
i'm working data foursquare api.
i want list of coffee shops, , getting correctly (i'm using restkit)... once list, on end need filter out coffee shop "starbucks".
so right know how pull in coffee shops, don't know how parse data once have before serve app table view there no starbucks coffee shops listed.
any ideas how that? let me know if need of code snippets posted might help. thanks!
edit
normal response type api be:
"venue": [{ "name": "abc coffee shop", {
so need take "name" , filter out name "starbucks"
.
if foursquare doesn't let apply filter request, filter on name "starbucks" following.
i start deserializing response json object, in case dictionary.
nserror *error = nil; nsdictionary *responsedict = [[nsjsonserialization jsonobjectwithdata:foursquareresponse options:0 error: &error]; nsarray *starbucks = nil; if (!error) { nsarray *coffeeshops = responsedict[@"venue"]; starbucks = [coffeeshops filteredarrayusingpredicate:[nspredicate predicatewithformat:@"name = 'starbucks'"]]; } else { // handle error } nslog(@"starbucks: %@", starbucks");
i didn't test code think should on way.
Comments
Post a Comment