var query = PFQuery(className: "University")
query.whereKey("classEnrolledName", equalTo:"fml")
query.findObjectsInBackgroundWithBlock {
(objects: [AnyObject]?, error: NSError?) -> Void in
if error == nil {
// The find succeeded.
NSLog("Successfully retrieved \(objects!.count) scores.")
// Do something with the found objects
if let objects = objects {
for object in objects {
NSLog("%@", object.objectId)
self.funlists.append(object.objectId)
}
}
} else {
// Log details of the failure
NSLog("Error: %@ %@", error!, error!.userInfo!)
}
}
两行都出错了
NSLog("%@", object.objectId)
和
self.funlists.append(object.objectId)
说我不能用类型字符串的参数列表调用?!
答案 0 :(得分:2)
objects:[AnyObject]?
是可选的。你需要打开它。 More info on optionals
if let objects = objects {
for object in objects {
NSLog("%@", object.objectId)
self.funlists.append(object.objectId)
}
}