0
我要檢查,如果一個PFObject
是零檢查零
我檢索對象
var userLibrary: PFObject?
func getUserLibrary(user: PFUser) {
self.libraryQuery = PFQuery(className: "Library")
self.libraryQuery?.whereKey("owner", equalTo: user)
self.libraryQuery?.findObjectsInBackgroundWithBlock({ (objects: [PFObject]?, error: NSError?) -> Void in
if error == nil {
if objects!.count > 0 {
self.userLibrary = objects![0]
} else {
print(self.userLibrary)
}
}
})
}
與打印語句打印最後一行出nil
。
然而,當我檢查:
if userLibrary != nil {
}
的Xcode告訴我
Binary operator '!=' cannot be applied to operands of type 'PFObject' and 'NilLiteralConvertible'
我該如何解決這個問題?