gpt4 book ai didi

ios - 使用 testflight 点击按钮时应用程序崩溃

转载 作者:行者123 更新时间:2023-11-28 11:39:43 27 4
gpt4 key购买 nike

我正在使用 Swift 4.2 开发应用程序,但我遇到了 iOS 应用程序崩溃的问题。对我来说一切正常,但它不适用于其他使用 testflight 安装应用程序的人。错误是这样的。 enter image description here

这是添加处理程序的代码。

cell.btnBooknow.addTarget(self, action: #selector(pressBookNowButton(button:)), for: .touchUpInside)

这是一个按钮点击处理程序。

@objc func pressBookNowButton(button: UIButton) {
guard let tagValue = self.arrListingBagHandler.object(at: button.tag) else {
return
}
print(self.artworks)

print(self.onlineStatus)
print(self.arrSearchAddressResult)


print(tagValue)
let valueStatus = tagValue["IsOnline"] as! String
let availability = tagValue["AvailabilityDays"] as! String
let arr = Array(availableDays)
print(valueStatus)
print(arr)
let arrAvailability = Array(availability)
print(arrAvailability)
let arr1 = availability.components(separatedBy: ",")
print(arr1)

let day = (presentDay!-1)
let today = "\(day)"
print(today)
if arr1.contains(today)
{
availableToday = true
}
else
{
availableToday = false
}

if valueStatus == "1" && availableToday == true
{
let obj = self.storyboard?.instantiateViewController(withIdentifier: "bookingId") as! BookingViewController
obj.dicBagHanlderDetail = tagValue
self.navigationController?.pushViewController(obj, animated: true)
}
else
{
let alert = UIAlertController(title: "Alert!", message: "You can't make booking because store is currently closed.", preferredStyle: .alert)
let okAction = UIAlertAction(title: "OK", style: .cancel) { (actoin) in
}
alert.addAction(okAction)
self.present(alert, animated: true, completion: nil)
}

}

谁能帮帮我?谢谢。

最佳答案

请使用以下功能并解决问题。我认为这是可能的,因为强制转换字符串和 int 值。

@objc func pressBookNowButton(button: UIButton) {
guard let tagValue = self.arrListingBagHandler.object(at: button.tag) else {
return
}




let valueStatus = tagValue["IsOnline"] as? String ?? ""
let availability = tagValue["AvailabilityDays"] as? String ?? ""
let arr = Array(availableDays)

let arrAvailability = Array(availability)

let arr1 = availability.components(separatedBy: ",")

let value : Int = Int(presentDay) ?? 0
let day = (value-1)
let today = "\(day)"

if arr1.contains(today)
{
availableToday = true
}
else
{
availableToday = false
}

if valueStatus == "1" && availableToday == true
{
let obj = self.storyboard?.instantiateViewController(withIdentifier: "bookingId") as! BookingViewController
obj.dicBagHanlderDetail = tagValue
self.navigationController?.pushViewController(obj, animated: true)
}
else
{
let alert = UIAlertController(title: "Alert!", message: "You can't make booking because store is currently closed.", preferredStyle: .alert)
let okAction = UIAlertAction(title: "OK", style: .cancel) { (actoin) in
}
alert.addAction(okAction)
self.present(alert, animated: true, completion: nil)
}

}

关于ios - 使用 testflight 点击按钮时应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54021499/

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