gpt4 book ai didi

ios - 我的应用程序很简单应用程序崩溃了

转载 作者:行者123 更新时间:2023-11-29 11:53:00 25 4
gpt4 key购买 nike

我做了一个小程序,我在工作时用它来计算保险箱里的钱。但是在更新我的 iPhone 后它崩溃了。我已经尝试了很多,但找不到解决方案。

当我按下激活以下功能的按钮时发生崩溃:

@IBAction func Knap(sender: AnyObject) {}

我是编码的新手,所以请尽可能简单地回答:)

我的应用如下:

//
// ViewController.swift
// Pengeskabstæller
//
// Created by Alex on 09/07/2016.
// Copyright © 2016 Alex. All rights reserved.
//

import UIKit


class ViewController: UIViewController, UITextFieldDelegate {

@IBOutlet weak var In50B: UITextField!
@IBOutlet weak var In50L: UITextField!
@IBOutlet weak var In20B: UITextField!
@IBOutlet weak var In20L: UITextField!
@IBOutlet weak var In10B: UITextField!
@IBOutlet weak var In10L: UITextField!
@IBOutlet weak var In5B: UITextField!
@IBOutlet weak var In5L: UITextField!
@IBOutlet weak var In2B: UITextField!
@IBOutlet weak var In2L: UITextField!
@IBOutlet weak var In1B: UITextField!
@IBOutlet weak var In1L: UITextField!
@IBOutlet weak var In05B: UITextField!
@IBOutlet weak var In05L: UITextField!
@IBOutlet weak var Ialt: UILabel!



override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.

}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
view.endEditing(true)
}

@IBAction func Knap(sender: AnyObject) {
//Hvad knappen gør

//Ganger input ved værdi af bundt eller løse
var x50B: Int = Int(In50B.text!)!
x50B = x50B*5000
var x50L:Int = Int(In50L.text!)!
x50L = x50L*500
var x20B:Int = Int(In20B.text!)!
x20B = x20B*4000
var x20L:Int = Int(In20L.text!)!
x20L = x20L*400
var x10B:Int = Int(In10B.text!)!
x10B = x10B*2000
var x10L:Int = Int(In10L.text!)!
x10L = x10L*200
var x5B:Int = Int(In5B.text!)!
x5B = x5B*1000
var x5L:Int = Int(In5L.text!)!
x5L = x5L*200
var x2B:Int = Int(In2B.text!)!
x2B = x2B*500
var x2L:Int = Int(In2L.text!)!
x2L = x2L*50
var x1B:Int = Int(In1B.text!)!
x1B = x1B*500
var x1L:Int = Int(In1L.text!)!
x1L = x1L*50
var x05B:Int = Int(In05B.text!)!
x05B = x05B*200
var x05L:Int = Int(In05L.text!)!
x05L = x05L*20

//Lægger det hele sammen

let penge1 = (x50B + x50L + x20B)
let penge2 = (x20L + x10B + x10L)
let penge3 = (x5B + x5L + x2B + x2L)
let penge4 = (x1B + x1L + x05B + x05L)
let penge99 = String(penge1+penge2+penge3+penge4)

//Printer ialt
Ialt.text = penge99
}

}

崩溃笔记是:

2016-10-30 01:13:57.687826 Pengeskabstæller[879:222437] -[Pengeskabstæller.ViewController Knap:]: unrecognized selector sent to instance 0x13fe0aac0
2016-10-30 01:13:57.688704 Pengeskabstæller[879:222437] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Pengeskabstæller.ViewController Knap:]: unrecognized selector sent to instance 0x13fe0aac0'
*** First throw call stack:
(0x1858641c0 0x18429c55c 0x18586b278 0x185868278 0x18576259c 0x18b6e19a0 0x18b6e1920 0x18b6cbdd0 0x18b6e120c 0x18b6e0d34 0x18b6dbf7c 0x18b6aca44 0x18be99ea8 0x18be93910 0x185812278 0x185811bc0 0x18580f7c0 0x18573e048 0x1871c1198 0x18b717818 0x18b712550 0x1000e9368 0x1847205b8)
libc++abi.dylib: terminating with uncaught exception of type NSException

最佳答案

替换这个:

@IBAction func Knap(sender: AnyObject)

有了这个

@IBAction func Knap(_ sender: AnyObject)

Swift 3 开始,如果您希望省略外部参数名称,则需要在外部参数名称前添加下划线。您的问题很可能是因为您在迁移到 Swift 3

之前添加了 IBActions

关于ios - 我的应用程序很简单应用程序崩溃了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40324555/

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