키를 사용하여 PFObject를 성공적으로 검색하는 데 문제가 있습니다. 결국 객체 무기 호 :키를 사용하여 PFObject 검색
var object = PFObject(className:"Topic")
var query = PFQuery(className:"Topic")
query.whereKey("title", equalTo:"Default")
query.getFirstObjectInBackgroundWithBlock {
(object: PFObject!, error: NSError!) -> Void in
if object != nil {
NSLog("The getFirstObject request failed.")
} else {
// The find succeeded.
NSLog("Successfully retrieved the object.")
}
}
개체의 검색에 성공하면
user.signUpInBackgroundWithBlock {
(succeeded: Bool!, error: NSError!) -> Void in
if error == nil {
NetworkManager.sharedInstance.follow(object, completionHandler: {
(error) ->() in
if error == nil {
}
else {
println("follow topic failure")
}
})
}
else {
println("signup failure")
}
}
}
테스트하려면 다음과 관계를 만들려면이 사용 :
println("this is the title of the default topic")
println(object["title"] as String)
콘솔 인쇄 :
this is the title of the default topic
fatal error: unexpectedly found nil while unwrapping an Optional value
: 여기
내가 개체를 인쇄하고
signUpInBackgroundWithBlock
에 대한 같은object
을 사용하는 일을 제안 무엇인가? –은 user.signupinbackground with block 바로 앞에 있습니다. 나는 그 문제가 있다고 생각하지 않는다. – user2913669
그것이 당신의 getFirstObjectInBackgroundWithBlock 외부에 있다면 그것은 확실히 문제이다. 나는 설명 할 것이다 ... 1 초 ... –