我现在已经收到这个updateRoot: anHtmlRoot
super updateRoot: anHtmlRoot.
anHtmlRoot meta
name: 'viewport';
content: 'width=device-width, initial-scale=1.0'
错误2天了,我无法理解为什么会这样做。错误指向我解析的特定查询。但是为了测试它是我的代码还是只是一个错误,我将这个EXACT块从Parse的查询文档复制到我的项目中作为函数:
Command failed due to signal: Segmentation fault: 11
它再次向该块发送错误.. Xcode也将此消息抛给我的编译器:
为什么会这样?
更新
所以看来凯文的答案通过让编译器告诉我类型而不是在var query = PFQuery(className:"GameScore")
query.whereKey("playerName", equalTo:"Sean Plott")
query.findObjectsInBackgroundWithBlock {
(objects: [AnyObject]?, error: NSError?) -> Void in
if error == nil {
// The find succeeded.
println("Successfully retrieved \(objects!.count) scores.")
// Do something with the found objects
if let objects = objects as? [PFObject] {
for object in objects {
println(object.objectId)
}
}
} else {
// Log details of the failure
println("Error: \(error!) \(error!.userInfo!)")
}
}
行中指定它来清除编译器错误,将其更正为:
query.findObjectsInBackgroundWithBlock {
(objects: [AnyObject]?, error: NSError?) -> Void in
但是这个其他块有点复杂,如何调整它以消除错误? :
query.findObjectsInBackgroundWithBlock {
(objects, error) -> Void in
}
答案 0 :(得分:1)
objects
实际上属于[PFObject]?
类型而不是[AnyObject]?
。一个疯狂的猜测会说根本原因试图向下倾斜。
无论如何,只需使用正确的类型来修复此
query.findObjectsInBackgroundWithBlock {
(objects: [PFObject]?, error: NSError?) -> Void in
}
或者让编译器告诉你类型
query.findObjectsInBackgroundWithBlock {
(objects, error) -> Void in
}
答案 1 :(得分:-1)
let query = PFQuery(className:"GameScore")
query.whereKey("playerName", equalTo:"Sean Plott")
query.findObjectsInBackgroundWithBlock {
(objects:[AnyObject]?, error:NSError?) -> Void in
if error == nil {
// The find succeeded.
print("Successfully retrieved \(objects!.count) scores.")
// Do something with the found objects
print(objects)
if let objects = objects {
for object in objects {
print(object.objectId)
}
}
} else {
// Log details of the failure
print("Error: \(error!) \(error!.userInfo)")
}
}
试试这个!它有效!