이름, 유형, 위치 등이있는 객체의 레스토랑이 있습니다. 전체 배열 객체를 검색하지 않고 레스토랑 이름이나 위치 만 검색하려면 어떻게해야합니까?스위프트의 배열 객체 내 검색
예를 들어 2 개의 레스토랑 개체가있는 배열입니다. Name에 "United"가 포함되어 있는지 검색하고 싶습니다. 전체 개체를 검색하면 국가 때문에 두 개체가 모두 표시됩니다.
[<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;
}]
이 객체의 어레이를 생성하는 블록이다
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)")
}
}
그는 신속하게 Objective - C – Leena
@ Leena에서 신속하게 'filteredArrayUsingPredicate'를 사용하는 데 어떤 문제가 있습니까? –
@VitaliyGozhenko 질문이 신속하고 객관적인 대답 대신 신속하게 응답해야한다고 말하고자합니다 ...... – Leena