gpt4 book ai didi

ios - Swift 每次内存地址跳转都会崩溃

转载 作者:行者123 更新时间:2023-12-01 16:38:14 27 4
gpt4 key购买 nike

在过去的三个小时里,这一直困扰着我,我似乎并没有完全理解它。

我有以下 IBOutlet:

@IBAction func simulateTheDay(sender: UIButton) {
if( self.iceCubesUsing == 0 || self.lemonsUsing == 0){
showAlertMessage(message: "You need to use at least one lemon or ice cube")
}

var numberOfCustomers = 0;
var winnings = 0;

self.lemonToIceCubeRatio = self.lemonsUsing / self.iceCubesUsing
self.lemonsToPurchase = 0
self.iceCubesToPurchase = 0
self.lemonsUsing = 0
self.iceCubesUsing = 0
self.customers = [];

do{
numberOfCustomers = Int(arc4random_uniform(UInt32(11)));
}while( numberOfCustomers == 0)

for(var i=0;i<numberOfCustomers;i++){
self.customers.append(Customer(preference: Double(arc4random_uniform(UInt32(101)))/101.0))
}
winnings = standBrain.calculateWinnings(self.customers, acidity: self.lemonToIceCubeRatio)
self.money += winnings

updateAssets()
}

任何地方的自我。是我类的一个全局变量。
每当我单击与此 socket 相关的按钮时,应用程序就会崩溃并在顶部突出显示我的 if() 语句,说“EXC_BAD_INSTRUCTION (code=EXCI386_INVOP, subcode=0x0)”

如果我将相同的代码复制到另一个 IBAction 中,它会完美运行。奇怪的地方来了。如果我删除 if 语句及其内容,它会在我的 while 语句中崩溃。如果我删除它,它会在我的 for 语句中崩溃。如果我什至删除它,它会在函数结束时崩溃,在所有情况下都会出现相同的错误消息。

如果我只离开: showAlertMessage(message: "You need to use at least one lemon or ice cube")它似乎没有跳到我的功能。

我尝试删除 IBOutlet 并重新创建它,尝试在我的 Storyboard中创建一个新的 UIButton,并将其链接到一个新的 IBOutlet,尝试清理项目,尝试清除 iOS 模拟器上的所有设置和数据。似乎没有任何效果。

这是以前的堆栈跟踪,如果它有帮助的话。
LemonadeStand`@objc LemonadeStand.ViewController.simulateTheDay (LemonadeStand.ViewController)(ObjectiveC.UIButton) -> () at ViewController.swift:
0x10466a800: pushq %rbp
0x10466a801: movq %rsp, %rbp
0x10466a804: subq $0x30, %rsp
0x10466a808: movq %rdx, -0x8(%rbp)
0x10466a80c: movq -0x8(%rbp), %rdx
0x10466a810: movq %rdi, -0x10(%rbp)
0x10466a814: movq %rdx, %rdi
0x10466a817: movq %rsi, -0x18(%rbp)
0x10466a81b: movq %rdx, -0x20(%rbp)
0x10466a81f: callq 0x10466e1a4 ; symbol stub for: objc_retain
0x10466a824: movq -0x10(%rbp), %rdi
0x10466a828: movq %rax, -0x28(%rbp)
0x10466a82c: callq 0x10466e1a4 ; symbol stub for: objc_retain
0x10466a831: movq -0x20(%rbp), %rdi
0x10466a835: movq -0x10(%rbp), %rsi
0x10466a839: movq %rax, -0x30(%rbp)
0x10466a83d: callq 0x10466a0e0 ; LemonadeStand.ViewController.simulateTheDay (LemonadeStand.ViewController)(ObjectiveC.UIButton) -> () at ViewController.swift:65
0x10466a842: addq $0x30, %rsp
0x10466a846: popq %rbp
0x10466a847: retq

编辑:添加了我的按钮的属性

Start Day Button Code

最佳答案

你在这里有正确的属性吗?

enter image description here

关于ios - Swift 每次内存地址跳转都会崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26447108/

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