将人员添加到联系人时,appstore中的应用程序崩溃了吗?

时间:2016-01-26 18:25:14

标签: ios swift crash abaddressbook

经过8天和一次小的元数据修复,我很高兴我的应用程序在应用程序商店中。但不幸的是,它在我女朋友的iPhone IOS 8.3上崩溃了,我在创建它时考虑到了8.1。

1 /这是我的第一个应用程序,在哪里可以找到我的应用程序的崩溃报告(如果存在)?

2 /如何在安装应用程序后检查联系人的授权?

3 /在联系人列表中添加联系人时,可能是导致崩溃的原因是什么?

    @IBAction func addToContacts(sender: AnyObject) {
        let authorizationStatus = ABAddressBookGetAuthorizationStatus()
        switch authorizationStatus {
        case .Denied, .Restricted:
            //1
        print("Denied")
        displayCantAddContactAlert()

        case .Authorized:
        //2
        print("Authorized")
        addVisitorToContacts()
        case .NotDetermined:
        //3
        print("Not Determined")
        promptForAddressBookRequestAccess(addContacts)
        }
        print("Add to contacts")
    }

     // MARK: - Permissions
        func promptForAddressBookRequestAccess(addContacts: UIButton) {
            //var err: Unmanaged<CFError>? = nil

            ABAddressBookRequestAccessWithCompletion(addressBookRef) {
                (granted: Bool, error: CFError!) in
                dispatch_async(dispatch_get_main_queue()) {
                    if !granted {
                        print("Just denied")
                        self.displayCantAddContactAlert()
                    } else {
                        print("Just authorized")
                        self.addVisitorToContacts()
                    }
                }
            }
        } 

addToContacts函数

func addVisitorToContacts() {

    let selectedVisitor = self.selectedVisitor!
    print(" hello \(selectedVisitor.sFirstName!) ")
    if let visitorRecordIfExists: ABRecordRef = getVisitorRecordCoreData(selectedVisitor) {// was 2
        displayContactExistsAlert(visitorRecordIfExists)
        return
    }
    let visitorRecord: ABRecordRef = makeAndAddVisitorRecordCoreData(selectedVisitor)
    let contactAddedAlert = UIAlertController(title: "\(selectedVisitor.sLastName!) added.",
        message: nil, preferredStyle: .Alert)
    contactAddedAlert.addAction(UIAlertAction(title: "Add 2 \"Visitors\" Group", style: .Default, handler: { action in
        self.addVisitorToGroup(visitorRecord)
    }))
    contactAddedAlert.addAction(UIAlertAction(title: "OK", style: .Cancel, handler: nil))
    presentViewController(contactAddedAlert, animated: true, completion: nil)
}

1 个答案:

答案 0 :(得分:1)

addVisitorToContact中,您打开所选联系人的姓名,在创建联系人时,这两个名称都不是必填字段。我的猜测是你试图解开一个零值,从而导致崩溃。

(为了检查将来的崩溃信息,我建议您在应用中安装Fabric。它是免费的。)