gpt4 book ai didi

ios - 由于未捕获的异常 'NSUnknownKeyException' 而终止应用程序,原因 : this class is not key value coding-compliant for the key Label2. '

转载 作者:搜寻专家 更新时间:2023-10-30 23:08:04 24 4
gpt4 key购买 nike

<分区>

这是我收到的确切错误消息:

Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[< Deetox.StoreViewController 0x102640610 > setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key Label2.'

我创建了一个信息按钮,它应该将用户带到我的应用程序的商店页面,但是当我点击信息按钮时它崩溃了。你们知道为什么吗?我该如何解决?非常感谢! ;)

这是我在 StoreViewController 上的代码:

import UIKit

import StoreKit

class StoreViewController: UIViewController, SKPaymentTransactionObserver, SKProductsRequestDelegate {

func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
}

@IBOutlet var Label1: UILabel!
@IBOutlet var Button1: UIButton!
@IBOutlet var Button2: UIButton!
@IBOutlet var BuyButton: UIButton!
@IBOutlet var ProductTitle: UILabel!
@IBOutlet var ProductDescription: UITextView!

var Product: SKProduct?
var ProductID = "co.AytacEren.Deetox.RemoveAds"

override func viewDidLoad() {
super.viewDidLoad()

Label1.layer.cornerRadius = 5.0
Button1.layer.cornerRadius = 5.0
Button2.layer.cornerRadius = 5.0
BuyButton.layer.cornerRadius = 5.0

BuyButton.isEnabled = false
SKPaymentQueue.default().add(self)
getPurchaseInfo()

// Do any additional setup after loading the view.
}

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

@IBAction func DismissView(_ sender: Any) {

self.dismiss(animated: true, completion: nil)

}

@IBAction func Purchase(_ sender: Any) {

let Payment = SKPayment(product: Product!)
SKPaymentQueue.default().add(Payment)

}

@IBAction func Restore(_ sender: Any) {

SKPaymentQueue.default().restoreCompletedTransactions()

}


func getPurchaseInfo() {

if SKPaymentQueue.canMakePayments() {

let request = SKProductsRequest(productIdentifiers: NSSet(objects: self.ProductID) as! Set<String>)

request.delegate = self
request.start()

}

else {

ProductTitle.text = "Warning"
ProductDescription.text = "Please enable In-App Purchase in your settings"

}

}

func productsRequest(_ request: SKProductsRequest, didReceive response: SKProductsResponse) {

var products = response.products

if (products.count == 0) {

ProductTitle.text = "Warning"
ProductDescription.text = "Product not found"

}

else {

Product = products [0]
ProductTitle.text = Product!.localizedTitle
ProductDescription.text = Product?.localizedDescription
BuyButton.isEnabled = true

}

let Invalids = response.invalidProductIdentifiers

for Product in Invalids {

print("Product not found: \(Product)")

}

}

func paymentQueue(_ queue: SKPaymentQueue, removedTransactions transactions: [SKPaymentTransaction]) {

for transaction in transactions {

switch transaction.transactionState {

case SKPaymentTransactionState.purchased:

SKPaymentQueue.default().finishTransaction(transaction)
ProductTitle.text = "Thank you"
ProductDescription.text = "You have purchased the product"
BuyButton.isEnabled = false

let save = UserDefaults.standard
save.set(true, forKey: "Purchase")
save.synchronize()

case SKPaymentTransactionState.restored:

SKPaymentQueue.default().finishTransaction(transaction)
ProductTitle.text = "Thank you"
ProductDescription.text = "You have purchased the product"
BuyButton.isEnabled = false

let save = UserDefaults.standard
save.set(true, forKey: "Purchase")
save.synchronize()

case SKPaymentTransactionState.failed:

SKPaymentQueue.default().finishTransaction(transaction)
ProductTitle.text = "Warning"
ProductDescription.text = "You have not purchased the product"

default:
break
}

}

}

}

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