Hi,
I'm using ABPeoplePicker to retrieve contacts and their number from the addressbook for adding persons to my view.
The problem is that sometimes the ABPeoplePicker crashes with this error:
unknown sandboxd[4537] : MyApplication(4533) deny file-write* /private/var/mobile/Applications/34C53A3F-82BE-4001-B520- 2B55D0C90624/Library/Preferences/com.apple.PeoplePicker.plist
The code doesn't crash every time, only sometimes when selecting a person, and then selecting the number.
This is testen on iOs 4.1
Here is my code:
-(void)showAddressBook
{
[[self navigationController] popViewControllerAnimated:YES];
ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
picker.peoplePickerDelegate = self;
NSArray *displayedItems = [NSArray arrayWithObjects:[NSNumber numberWithInt:kABPersonPhoneProperty], nil];
picker.displayedProperties = displayedItems;
[self presentModalViewController:picker animated:YES];
[picker release];
}
-(void) peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker {<br>
[self dismissModalViewControllerAnimated:YES];
}
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person {
return YES;
}
-(BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier {
ABMultiValueRef phoneProperty = ABRecordCopyValue(person,property);
CFStringRef ph = ABMultiValueCopyValueAtIndex(phoneProperty,identifier);
CFStringRef fn = ABRecordCopyValue(person, kABPersonFirstNameProperty);
CFStringRef ln = ABRecordCopyValue(person, kABPersonLastNameProperty);
NSString *firstName = [NSString stringWithFormat:@"%@", fn];
NSString *lastName = [NSString stringWithFormat:@"%@", ln];
NSString *personNumber = [NSString stringWithFormat:@"%@", ph];
CFRelease(fn);
CFRelease(ln);
CFRelease(ph);
CFRelease(phoneProperty);
Person *participantPerson = [Person createPersonWithNumber:personNumber AndFirstName:firstName AndLastName:lastName];
[contentViewController addPerson:participantPerson];
[self dismissModalViewControllerAnimated:YES];
return NO;
}
I can't see what I'm doing wrong or where I'm trying to write to PeoplePicker.plist. Been trying to figure this out for a long time, am a bit stuck. Anyone have an idea about what could be wrong, please?