0
我試圖從objects
中提取prayerRequest
。但是,我並不確定如何完成此操作。解析對象中的特定字段
var allPrayerRequests = [""]
override func viewDidLoad() {
super.viewDidLoad()
var query = PFQuery(className: "PrayerRequests")
query.findObjectsInBackgroundWithBlock({ (objects, error) -> Void in
if error == nil {
if let objects = objects as? [PFObject] {
for object in objects {
println(object)
}
}
}
})
}
如果我這樣做,println(object)
,我得到下面的輸出:
<PrayerRequests: 0x7feec8eec7f0, objectId: jy2KwGXenC, localId: (null)> {
ACL = "<PFACL: 0x7feec8eca220>";
prayerRequest = qoiejr;
}
<PrayerRequests: 0x7feec8eed9a0, objectId: KxMpxyWV0P, localId: (null)> {
ACL = "<PFACL: 0x7feec8eed600>";
prayerRequest = qwer;
}
<PrayerRequests: 0x7feec8eee5f0, objectId: DRHBwJpq16, localId: (null)> {
ACL = "<PFACL: 0x7feec8eee840>";
prayerRequest = zxcv;
}
<PrayerRequests: 0x7feec8eeecd0, objectId: cOOdOyv4TM, localId: (null)> {
ACL = "<PFACL: 0x7feec8eeef10>";
prayerRequest = oijg;
}
<PrayerRequests: 0x7feec8eef3c0, objectId: bmO3oVKUDG, localId: (null)> {
ACL = "<PFACL: 0x7feec8eef680>";
prayerRequest = asdf;
}
<PrayerRequests: 0x7feec8eef800, objectId: RcR3wbbMYv, localId: (null)> {
ACL = "<PFACL: 0x7feec8eefda0>";
prayerRequest = qwer;
}
所以,你可以在代碼中看到,有一個與prayerRequest
場。我希望能夠如果我是做println(object.objectId)
,其輸出以下控制檯只提取這個領域有點像:
Optional("jy2KwGXenC")
Optional("KxMpxyWV0P")
Optional("DRHBwJpq16")
Optional("cOOdOyv4TM")
Optional("bmO3oVKUDG")
Optional("RcR3wbbMYv")
但只是prayerRequest
領域。任何人都有辦法做到這一點?
試試這個object.objectForKey( 「prayerRequest」) –
YES!有效。天啊。非常感謝! –