我使用Branch SDK获取iOS应用程序的深层链接。如果您快速向第三方应用程序(例如,Slack,Facebook)发送深层链接,则会出现问题,然后发生应用程序崩溃。控制台显示以下结果import UIKit
import CoreData
class ItemDetailsVC: UIViewController, UIPickerViewDelegate, UIPickerViewDataSource {
@IBOutlet weak var storePicker: UIPickerView!
@IBOutlet weak var detailsField: CustomTextField!
@IBOutlet weak var priceField: CustomTextField!
@IBOutlet weak var titleField: CustomTextField!
var stores = [Store]()
var itemToEdit: Item?
override func viewDidLoad() {
super.viewDidLoad()
storePicker.delegate = self
storePicker.dataSource = self
// let store = Store(context: context)
// store.name = "Amazon"
// let store1 = Store(context: context)
// store1.name = "Flipkart"
// let store2 = Store(context: context)
// store2.name = "Snapdeal"
// let store3 = Store(context: context)
// store3.name = "Bigbasket"
// let store4 = Store(context: context)
// store4.name = "Groffers"
// ad.saveContext()
getStores()
if itemToEdit != nil{
loadItemData()
}
if let topItem = self.navigationController?.navigationBar.topItem {
topItem.backBarButtonItem = UIBarButtonItem(title: "", style: UIBarButtonItemStyle.plain, target: nil, action: nil)
}
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
let store = stores[row]
return store.name
}
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
return stores.count
}
func numberOfComponents(in pickerView: UIPickerView) -> Int {
return 1
}
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
//Update
}
func getStores(){
let fetchRequest: NSFetchRequest<Store> = Store.fetchRequest()
do{
self.stores = try context.fetch(fetchRequest)
self.storePicker.reloadAllComponents()
}catch{
//Handles the error
}
}
@IBAction func savePressed(_ sender: Any) {
var item: Item!
if itemToEdit == nil{
item = Item(context: context)
}else{
item = itemToEdit
}
if let title = titleField.text{
item.title = title
}
if let price = priceField.text{
item.price = (price as NSString).doubleValue
}
if let details = detailsField.text{
item.details = details
}
item.toStore = stores[storePicker.selectedRow(inComponent: 0)]
navigationController?.popViewController(animated: true)
}
func loadItemData(){
if let item = itemToEdit{
titleField.text = item.title
priceField.text = "\(item.price)"
detailsField.text = item.details
if let store = item.toStore{
var index = 0
repeat{
let s = stores[index]
if s.name == store.name{
storePicker.selectRow(index, inComponent: 0, animated: false)
break
}
index += 1
}while index < stores.count
}
}
}
}
如何解决?
我的代码
[core] SLComposeViewController dealloc <SLComposeViewController: 0x11fbf03a0>.