I have an array of restaurants that are objects with name, type, location, etc. How can I search for just a restaurant name, or just a location without searching the entire array object?
For example my array with 2 Restaurant objects. I only want to search if Name contains "United". If i search the entire object, both will show up because of the country.
[<Restaurant: 0x7fcb0ad80950, objectId: LA74J92QDA, localId: (null)> {
City = "New York";
Country = "United States";
Name = United Bakery;
RestaurantLoc = "<PFGeoPoint: 0x7fcb0af6cbc0, latitude: 40.759212, longitude: -73.984632>";
State = NY;
Street = "1 main st.";
Zipcode = 10055;
}, <Restaurant: 0x7fcb0af6cfc0, objectId: 0aKFrpKN46, localId: (null)> {
City = "New York";
Country = "United States";
Name = Wendys Bakery;
RestaurantLoc = "<PFGeoPoint: 0x7fcb0af6cd60, latitude: 40.759210, longitude: -73.984631>";
State = NY;
Street = "1 main st.";
Zipcode = 10055;
}]
This is the block that creates the array of objects:
let userGeoPoint = currentLocGeoPoint
var query = PFQuery(className:"Restaurant")
query.whereKey("RestaurantLoc", nearGeoPoint:userGeoPoint, withinMiles:50)
query.limit = 2
query.findObjectsInBackgroundWithBlock {
(object: [AnyObject]!, error: NSError!) -> Void in
if object != nil {
println(object)
} else {
println("The getObject request failed with error: \(error)")
}
}