Advertisement
Guest User

Untitled

a guest
Aug 29th, 2015
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. ABMultiValueRef phones = ABRecordCopyValue(contactPerson, kABPersonPhoneProperty);
  2. for (NSUInteger j = 0; j < ABMultiValueGetCount(phones); j++) {
  3.  
  4. NSMutableString *phone = [CFBridgingRelease(ABMultiValueCopyValueAtIndex(phones, j)) mutableCopy];
  5.  
  6. [phone replaceOccurrencesOfString:@" " withString:@"" options:0 range:NSMakeRange(0, phone.length)];
  7. [phone replaceOccurrencesOfString:@"(" withString:@"" options:0 range:NSMakeRange(0, phone.length)];
  8. [phone replaceOccurrencesOfString:@")" withString:@"" options:0 range:NSMakeRange(0, phone.length)];
  9. [phone replaceOccurrencesOfString:@"-" withString:@"" options:0 range:NSMakeRange(0, phone.length)];
  10. [phone replaceOccurrencesOfString:@"+33" withString:@"0" options:0 range:NSMakeRange(0, phone.length)];
  11. [phone stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
  12.  
  13. if (((j == 0) && [phone hasPrefix:@"06"]) || ((j == 0) && [phone hasPrefix:@"07"])) person.mainNumber = phone;
  14. else if ((j==1) && [phone hasPrefix:@"06"]) person.mainNumber = phone;
  15. else if ((j==2) && [phone hasPrefix:@"06"]) person.mainNumber = phone;
  16. else if ((j==3) && [phone hasPrefix:@"06"]) person.mainNumber = phone;
  17. }
  18. CFRelease(phones);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement