gpt4 book ai didi

ios - Bitcast 要求两个操作数都是指针,或者 Swift 编译器都不会出错

转载 作者:行者123 更新时间:2023-11-28 09:20:58 25 4
gpt4 key购买 nike

我在使用 Swift 时遇到了一个严重的错误,尽管进行了大量研究,但我没有在 Google 上找到任何帮助。

Bitcast requires both operands to be pointer or neither %116 = bitcast i8* %115 to %SS, !dbg !249 Invalid operand types for ICmp instruction %117 = icmp ne %SS %116, null, !dbg !249 PHI nodes must have at least one entry. If the block is dead, the PHI should be removed! %120 = phi i32 PHI node operands are not the same type as the result! %119 = phi i8* [ %116, %108 ] LLVM ERROR: Broken function found, compilation aborted!

我真的不知道这个错误发生在哪里,因为经过一些重构,我在很多文件中进行了更改。

我决定创建一个问答式的帖子来帮助其他开发者找出这个错误的含义。

希望对您有所帮助!

最佳答案

我在数小时内评论/取消评论我项目的所有代码后,终于找到了导致错误的行,该错误已发布在我的原始帖子中。

class LoginAccountViewController : UIViewController
{
@IBOutlet var loginFacebook : UIButton?
@IBOutlet var emailField : UITextField?

override func viewDidLoad()
{
super.viewDidLoad()
}

override func viewWillAppear(animated: Bool)
{
super.viewWillAppear(animated)
}

@IBAction func loginEmail(sender: AnyObject)
{
if let emailAddress = emailField?.text as? String // THIS IS THE BAD LINE
{
}
}
}

错误是我试图对一个名为 text 的属性进行展开向下转换,该属性不是可选的,因为包含该属性的对象是可选的。这是一个大错误。

好的解决方案是对 emailField 属性进行展开向下转换,然后,不需要展开 text 属性即可访问其值。

if let emailAddress = emailField as? UITextField
{
println(emailAddress.text)
}

关于ios - Bitcast 要求两个操作数都是指针,或者 Swift 编译器都不会出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24649823/

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