-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNSObject+text.m
57 lines (41 loc) · 1.89 KB
/
NSObject+text.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//
// NSObject+text.m
// ToDoBeta
//
// Created by MAYUR on 10/04/15.
// Copyright (c) 2015 MAYUR. All rights reserved.
//
#import "NSObject+text.h"
@implementation NSObject (text)
// NSString *phoneNumber = [@"tel://" stringByAppendingString:@"9414481799"];
//[[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumber]];
- (void)opencontacts {
ABPeoplePickerNavigationController *contactpicker = [[ABPeoplePickerNavigationController alloc] init];
contactpicker.peoplePickerDelegate = self;
[self presentViewController:contactpicker animated:YES completion:nil];
}
- (void)peoplePickerNavigationControllerDidCancel:
(ABPeoplePickerNavigationController *)peoplePicker {
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker didSelectPerson:(ABRecordRef)person
{
ABMultiValueRef phone = (ABMultiValueRef) ABRecordCopyValue(person, kABPersonPhoneProperty);
CFStringRef phoneID = ABMultiValueCopyValueAtIndex(phone, 0);
name = (__bridge_transfer NSString*)ABRecordCopyValue(person,kABPersonFirstNameProperty);
number=(__bridge NSString *)(phoneID);
txtdesc.text=[NSString stringWithFormat:@"Call %@ %@",name,number];
CFRelease(phoneID);
CFRelease(phone);
[self dismissViewControllerAnimated:YES completion:nil];
}
-(BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier{
return NO;
}
- (void)addContactFromPhoneContacts:(id)sender
{
ABPeoplePickerNavigationController *contactpicker = [[ABPeoplePickerNavigationController alloc] init];
contactpicker.peoplePickerDelegate = self;
[self presentViewController:contactpicker animated:YES completion:nil];
}
@end