0

こんにちは、私はアプリを作成していますが、iPhone の連絡先にアクセスし、必要な電話番号をクリックして使用できるようにするにはどうすればよいか考えていました。

更新しました - - -

私はAdobe Flash CS5.5の開発者です

4

1 に答える 1

0

連絡先の名前、番号などを使用するためのクラスAddressBook.frameworkも含める必要があります。MContact

#import <AddressBook/AddressBook.h>
#import <AddressBook/ABAddressBook.h>
#import <AddressBook/ABPerson.h>

[contactList removeAllObjects];

// open the default address book. 
ABAddressBookRef m_addressbook = ABAddressBookCreate();
if (!m_addressbook) {
    NSLog(@"opening address book");
}

// can be cast to NSArray, toll-free
CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople(m_addressbook);
CFIndex nPeople = ABAddressBookGetPersonCount(m_addressbook);

// CFStrings can be cast to NSString!

for (int i=0;i < nPeople;i++) { 
 MContact *contact = [[MContact alloc] init];

 ABRecordRef ref = CFArrayGetValueAtIndex(allPeople,i);
 CFStringRef firstName, lastName;
 firstName = ABRecordCopyValue(ref, kABPersonFirstNameProperty);
 lastName  = ABRecordCopyValue(ref, kABPersonLastNameProperty);
 contact.name = [NSString stringWithFormat:@"%@ %@", firstName, lastName];

 ABMutableMultiValueRef eMail  = ABRecordCopyValue(ref, kABPersonEmailProperty);
 if(ABMultiValueGetCount(eMail) > 0) {
  contact.email =  (NSString *)ABMultiValueCopyValueAtIndex(eMail, 0);
  [contactList addObject:contact];
 }

 CFRelease(ref);
 CFRelease(firstName);
 CFRelease(lastName);


}

////and here MContact is NObject (Bean) file bellow

@interface MContact : NSObject { 
NSString *email; 
NSString *name; 
NSString *lastName; 
NSString *phone; 

BOOL isSelected; 
} 
@property (nonatomic, retain) NSString *email; 
@property (nonatomic, retain) NSString *name; 
@property (nonatomic, retain) NSString *lastName; 
@property (nonatomic, retain) NSString *phone; 

@property (nonatomic) BOOL isSelected; 
@property (nonatomic, readonly) NSString *displayName; 
@end
于 2012-11-06T05:07:17.433 に答える