Xcode错误:由于信号命令失败:分段错误:11

时间:2015-09-21 17:44:53

标签: xcode swift

我在运行时收到错误“命令因信号失败:分段错误:11”。我相信这是一个编译错误,因为当我清理我的代码时它没有任何错误,只有当我运行&建立。我正在使用新的Xcode beta 7.1。我也通过我的Xcode 7.0构建它但收到了同样的错误。

之前构建的Swift代码没有错误。此代码处理Parse后端并查询某些信息以显示给用户;这是以下日志:

  1.    While type-checking 'viewDidLoad' at /Users/User/Documents/Documents/ProjectName/UserProfile.swift:27:14
2.  While type-checking expression at [/Users/User/Documents/Documents/ProjectName/UserProfile.swift:34:9 - line:55:9] RangeText="query.findObjectsInBackgroundWithBlock {
        (objects: [AnyObject]?, error: NSError?) -> Void in

        if error == nil {
            if let objects = objects as? [PFObject] {
                for object in objects {
                    let userImageFile: PFFile = object.objectForKey("ProfPhoto") as! PFFile
                    userImageFile.getDataInBackgroundWithBlock {
                        (imageData: NSData?, error: NSError?) -> Void in
                        if error == nil {
                            if let imageData = imageData {
                                self.ProfileImage.image = UIImage(data:imageData)
                            }
                        }
                    }
                }
            }
        } else {
            // Log details of the failure
            print("Error: \(error!) \(error!.userInfo)")
        }
    }"
 3. While type-checking expression at [/Users/User/Documents/Documents/ProjectName/UserProfile.swift:34:9 - line:55:9] RangeText="query.findObjectsInBackgroundWithBlock {
        (objects: [AnyObject]?, error: NSError?) -> Void in

        if error == nil {
            if let objects = objects as? [PFObject] {
                for object in objects {
                    let userImageFile: PFFile = object.objectForKey("ProfPhoto") as! PFFile
                    userImageFile.getDataInBackgroundWithBlock {
                        (imageData: NSData?, error: NSError?) -> Void in
                        if error == nil {
                            if let imageData = imageData {
                                self.ProfileImage.image = UIImage(data:imageData)
                            }
                        }
                    }
                }
            }
        } else {
            // Log details of the failure
            print("Error: \(error!) \(error!.userInfo)")
        }
    }"
  4.    While type-checking expression at [/Users/User/Documents/Documents/ProjectName/UserProfile.swift:34:48 - line:55:9] RangeText="{
        (objects: [AnyObject]?, error: NSError?) -> Void in

        if error == nil {
            if let objects = objects as? [PFObject] {
                for object in objects {
                    let userImageFile: PFFile = object.objectForKey("ProfPhoto") as! PFFile
                    userImageFile.getDataInBackgroundWithBlock {
                        (imageData: NSData?, error: NSError?) -> Void in
                        if error == nil {
                            if let imageData = imageData {
                                self.ProfileImage.image = UIImage(data:imageData)
                            }
                        }
                    }
                }
            }
        } else {
            // Log details of the failure
            print("Error: \(error!) \(error!.userInfo)")
        }
    }"

2 个答案:

答案 0 :(得分:2)

我已经搜索了为什么错误:"命令由于信号而失败:分段错误:11"在我的应用程序中导致问题...我的应用程序是Parse依赖的。我发现Parse对方法进行了更改:

    query.findObjectsInBackgroundWithBlock({ (objects : [AnyObject]?, error : NSError?) -> Void in

    query.findObjectsInBackgroundWithBlock({ (objects : [**PFObject**]?, error : NSError?) -> Void in

我已经改变了一切,现在它起作用了。希望这会帮助使用Parse的人。感谢用户Babac。

答案 1 :(得分:0)

这个问题的好答案是改变方法:

 query.findObjectsInBackgroundWithBlock({ (objects : [PFObject]?, error : NSError?) -> Void in

到此:

query.findObjectsInBackgroundWithBlock({ (objects : [AnyObject]?, error : NSError?) -> Void in

因为唯一要改变的是[PFObject]?[AnyObject]?,那么您的代码就可以正常运行; - )