Created
October 13, 2011 22:52
-
-
Save niw/1285768 to your computer and use it in GitHub Desktop.
Remove all URLs from AddressBook.app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <AddressBook/AddressBook.h> | |
int main() { | |
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; | |
ABAddressBook *addressBook = [ABAddressBook sharedAddressBook]; | |
ABSearchElement *searchElement = [ABPerson searchElementForProperty:kABURLsProperty | |
label:nil | |
key:nil | |
value:@"http://" | |
comparison:kABPrefixMatch]; | |
NSArray *personFound = [addressBook recordsMatchingSearchElement:searchElement]; | |
for(ABPerson* person in personFound) { | |
NSLog(@"%@ %@: %@", [person valueForProperty:kABFirstNameProperty], | |
[person valueForProperty:kABLastNameProperty], | |
[person valueForProperty:kABURLsProperty]); | |
[person removeValueForProperty:kABURLsProperty]; | |
} | |
[addressBook save]; | |
[pool release]; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment