gpt4 book ai didi

ios - 如何解决由于信号: Segmentation fault: 11导致命令失败的问题

转载 作者:行者123 更新时间:2023-11-30 13:20:02 25 4
gpt4 key购买 nike

我在这里搜索这个问题,发现这个问题并不常见。

每个人都有不同的方法来解决这个问题。我正在使用 Firebase 和 Gifu 框架。实际上对于最后一个 - 我将所有文件复制到我的项目中,但这也没有帮助。

这是我的源代码:

import FirebaseDatabase
import FirebaseAuth
import Firebase
import UIKit
import Gifu

class ViewController: UIViewController {

@IBOutlet weak var userImage: AnimatableImageView!

var displayedUserId = ""
var AcceptedOrRejected = ""


override func viewDidLoad() {
super.viewDidLoad()

let urlArray = ["http://i.imgur.com/VAWlQ0S.gif", "http://i.imgur.com/JDzGqvE.gif", "http://67.media.tumblr.com/4cd2a04b60bb867bb4746d682aa60020/tumblr_mjs2dvWX6x1rvn6njo1_400.gif", "https://media.giphy.com/media/TlK63ELk5OPDzpb6Tao/giphy.gif", "http://i3.photobucket.com/albums/y90/spicestas/GeriHalliwell-Calling-new1.gif", "http://media.tumblr.com/tumblr_lnb9aozmM71qbxrlp.gif"]

var counter = 1

for url in urlArray {

let nsUrl = NSURL(string: url)

let girls = ProfileClass()

girls.profilePhotoUrl = url
girls.profileGender = "female"
girls.profileName = "girlsname\(counter)"
girls.profileSurname = "girlsurname\(counter)"
girls.interest = "men"
girls.uid = "\(randomStringWithLength(45))"

counter++
girls.SaveUser()


}

//----setting variables


let label = UILabel(frame: CGRectMake(self.view.bounds.width / 2 - 100, self.view.bounds.height / 2 - 50, 300, 100))
//label.text = "Drag me!"
//label.textAlignment = NSTextAlignment.Center
self.view.addSubview(label)

let gesture = UIPanGestureRecognizer(target: self, action: Selector("wasDragged:"))
userImage.addGestureRecognizer(gesture)
userImage.userInteractionEnabled = true



//----getting access to database

let thisUserRef = URL_BASE.childByAppendingPath("profile")


thisUserRef.queryOrderedByChild("Interest").queryEqualToValue("men").observeEventType(.Value, withBlock: {
snapshot in

for child in snapshot.children{

self.displayedUserId = (child.value["uid"] as? String)!

let imageURL = child.value["photo"] as? String

let imURL = NSURL(string: imageURL!)

//print(imageURL)



if self.AcceptedOrRejected != "" {

let AcceptedArray = child.value[AcceptedOrRejected] as? Array

AcceptedArray.append(displayedUserId)

}







if let picData = NSData(contentsOfURL: imURL!) {

self.userImage.animateWithImageData(picData)
//self.userImage.image = UIImage(data: picData)
}


}


})






}

//-----Dragging function-----------

func wasDragged(gesture: UIPanGestureRecognizer) {

//set traslations
let translation = gesture.translationInView(self.view)
let label = gesture.view



//set center position
label!.center = CGPoint(x: self.view.bounds.width / 2 + translation.x, y: self.view.bounds.height / 2 - translation.y )

let xfromCenter = (label?.center.x)! - self.view.bounds.width / 2

let scale = min(100 / abs(xfromCenter),1)

var rotation = CGAffineTransformMakeRotation(xfromCenter / 200)

var strech = CGAffineTransformScale(rotation, scale, scale)

label?.transform = strech



if gesture.state == UIGestureRecognizerState.Ended {

if label?.center.x < 100 {

self.AcceptedOrRejected = "Accepted"


} else if label?.center.x > self.view.bounds.width / 100 {

self.AcceptedOrRejected = "Rejected"

}

rotation = CGAffineTransformMakeRotation(0)
strech = CGAffineTransformScale(rotation, 1, 1)

label?.transform = strech

label?.center = CGPoint(x: self.view.bounds.width / 2 , y: self.view.bounds.height / 2 )
}

}


//---Function for generating randomn userid


func randomStringWithLength (len : Int) -> NSString {

let letters : NSString = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"

let randomString : NSMutableString = NSMutableString(capacity: len)

for (var i=0; i < len; i += 1){
let length = UInt32 (letters.length)
let rand = arc4random_uniform(length)
randomString.appendFormat("%C", letters.characterAtIndex(Int(rand)))
}

return randomString
}



override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()


}


override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {

if segue.identifier == "LogOutSegue" {
try! FIRAuth.auth()!.signOut()
}


}

}

我收到此错误

1.  While emitting SIL for 'viewDidLoad' at /Users/zkid18/Desktop/wrk/Bloom/Bloom/ViewController.swift:23:14
2. While silgen closureexpr SIL function @_TFFC5Bloom14ViewController11viewDidLoadFT_T_U_FCSo15FIRDataSnapshotT_ for expression at [/Users/zkid18/Desktop/wrk/Bloom/Bloom/ViewController.swift:68:114 - line:107:9] RangeText="{
snapshot in

for child in snapshot.children{

self.displayedUserId = (child.value["uid"] as? String)!

let imageURL = child.value["photo"] as? String

let imURL = NSURL(string: imageURL!)

//print(imageURL)



if self.AcceptedOrRejected != "" {

let AcceptedArray = child.value[AcceptedOrRejected] as? Array

AcceptedArray.append(displayedUserId)

}







if let picData = NSData(contentsOfURL: imURL!) {

self.userImage.animateWithImageData(picData)
//self.userImage.image = UIImage(data: picData)
}


}


}"

我真的不知道该怎么办

最佳答案

我刚刚尝试转换为 Swift 3,以快速解决代码中的问题。我有类似的错误,但我只是将 Firebase 集成到我的所有项目中。我发现通过从应用程序中删除 pod 和框架并注释掉所有 firebase 代码修复了这个编译问题。

关于ios - 如何解决由于信号: Segmentation fault: 11导致命令失败的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37863119/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com