ABRecordCopyCompositeName和CFBridgingRelease崩溃问题

时间:2017-08-26 03:29:55

标签: ios iphone sorting crash addressbook

我正在使用AddressBook开发IOS应用程序。

这是我使用的代码。

我在substringWithRange函数上遇到崩溃问题。

崩溃的原因是什么?

谢谢。

NSString * sort_name = CFBridgingRelease(ABRecordCopyCompositeName(person));
if (sort_name != nil) {
    [self Make_Sorting_Name:sort_name];


- (NSDictionary *)Make_Sorting_Name:(NSString *)sort_name {

            NSString * sort_char = [[NSString stringWithString:[sort_name substringWithRange:NSMakeRange(0, 1)]] uppercaseString];

            NSCharacterSet *nonDigits = [NSCharacterSet letterCharacterSet];
            BOOL containsNonDigitChars = ([sort_char rangeOfCharacterFromSet:nonDigits].location == NSNotFound);            

        }

1 个答案:

答案 0 :(得分:1)

destroy(){ swal({ title: "Delete this comment?", text: "Are you sure? You won't be able to revert this!", type: "warning", showCancelButton: true, confirmButtonColor: "#3085d6", confirmButtonText: "Yes, Delete it!", closeOnConfirm: true }, function(){ axios.delete('/comment/' + this.comment.id + '/delete'); $(this.$el).fadeOut(300, () => { return toastr.success('Comment deleted.'); }); }); }, 函数有时可能返回nil或空字符串。因此需要检查案例:

ABRecordCopyCompositeName