Domanda

Hi i have an error in a crash log that i cannot understand:

Incident Identifier: A0DFD1F1-8CB5-4D97-B19C-F73438F50136
CrashReporter Key:   [TODO]
Hardware Model:      iPhone4,1
Process:         Rubrica4146 [1163]
Path:            /var/mobile/Applications/A8BF5FB7-C32B-4A8C-A7AA-E6F6D94DF2EB/Rubrica4146.app/Rubrica4146
Identifier:      com.7shapes.rubrica4146
Version:         27
Code Type:       ARM
Parent Process:  launchd [1]

Date/Time:       2013-09-20 15:38:31 +0000
OS Version:      iPhone OS 7.0 (11A465)
Report Version:  104

Exception Type:  SIGSEGV
Exception Codes: SEGV_ACCERR at 0xc0000004
Crashed Thread:  0

Thread 0 Crashed:
0   CoreFoundation                      0x303b004c CFRetain + 8
1   Rubrica4146                         0x000ce3d3 -[AppDelegate personViewController:shouldPerformDefaultActionForPerson:property:identifier:] (AppDelegate.m:752)
2   AddressBookUI                       0x2fb61385 -[ABPersonViewController_Modern contactViewController:shouldPerformDefaultActionForContact:property:labeledValue:] + 177
3   AddressBookUI                       0x2faf0133 -[ABContactViewController tableView:didSelectRowAtIndexPath:] + 659
4   UIKit                               0x32d1032b -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1079
5   UIKit                               0x32dc3253 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 215
6   UIKit                               0x32c73971 _applyBlockToCFArrayCopiedToStack + 317
7   UIKit                               0x32beb473 _afterCACommitHandler + 431
8   CoreFoundation                      0x3044d1d5 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 21
9   CoreFoundation                      0x3044ab79 __CFRunLoopDoObservers + 285
10  CoreFoundation                      0x3044aebb __CFRunLoopRun + 731
11  CoreFoundation                      0x303b5ce7 CFRunLoopRunSpecific + 523
12  CoreFoundation                      0x303b5acb CFRunLoopRunInMode + 107
13  GraphicsServices                    0x350d6283 GSEventRunModal + 139
14  UIKit                               0x32c57a41 UIApplicationMain + 1137
15  Rubrica4146                         0x000ca6af main (main.m:16)

and this is the method that seems to generate it:

-(BOOL) personViewController:(ABPersonViewController *)personViewController shouldPerformDefaultActionForPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier{
    if (property == kABPersonPhoneProperty){
        NSString *number = nil;
        ABMultiValueRef phoneNumbers = ABRecordCopyValue(person, property);
        if (ABMultiValueGetCount(phoneNumbers) > 0) {
            number = (__bridge_transfer NSString*)ABMultiValueCopyValueAtIndex(phoneNumbers, identifier);
            [self setInfoForPersonToCall:person];
            self.numberToSave = number;
            self.numberToCall = number;
            if (self.shouldSendSMS) {
                [self prepareToSMSNumber];
            } else {
                [self prepareToCallNumber];
            }
        }
        if (phoneNumbers != nil)
            CFRelease(phoneNumbers);
    }
    return NO;
}

Does anybody know how to fix it? I believe there is an issue with ARC memory management and with __bridge_transfer. thanks

È stato utile?

Soluzione

Try iterating thru a contact's phone numbers (the kABPersonPhoneProperty multivalue), using CFBridgingRelease:

// Access the person's phone numbers (an ABMultiValueRef)
ABMultiValueRef phoneProperty = ABRecordCopyValue(person, kABPersonPhoneProperty);

if (phoneProperty)
{
    // Iterate through the phone multivalue
    for (CFIndex index = 0; index < ABMultiValueGetCount(phoneProperty); index++)
    {
        // Get the phone identifier for this phone property
        ABMultiValueIdentifier phoneIdentifier = ABMultiValueGetIdentifierAtIndex(phoneProperty, index);

        // Get the phone number
        NSString *phoneNumber = CFBridgingRelease(ABMultiValueCopyValueAtIndex(phoneProperty, index));
    }
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top