大家.. 我正在尝试开发一个iPhone应用程序,它基本上处理ABAddressBook
和联系人数据... 我的目标是发送所有联系人数据(第一步,姓名和电话)在通过e-mail文件..xcode中的联系人数据
现在,我想达到的联系人数据,我想将它们添加到两个不同的阵列,姓名和电话阵列..
起初,我当我按下“列表联系人”按钮时,试图查看屏幕中的所有数据。数据应该在屏幕上看到。然后当我按下第二个按钮“发送联系人”,应该将文件发送到电子邮件帐户。这是我的应用程序将如何工作..
我有在显示屏幕上的数据问题..我写的东西,但它不能在一个TextView给屏幕上的任何.. 你能帮我解决这个问题?
下面的代码上市触点(listCon法):
-(IBAction)listCon:(id)sender
{
NSMutableArray *names = [[NSMutableArray alloc] init];
NSMutableArray *numbers1= [[NSMutableArray array] init];
NSMutableArray *numbers2= [[NSMutableArray array] init];
NSMutableArray *numbers3= [[NSMutableArray array] init];
ABAddressBookRef addressBook = ABAddressBookCreate();
if (addressBook != nil)
{
NSLog(@"Successfully accessed the address book.");
CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople(addressBook);
CFIndex nPeople= ABAddressBookGetPersonCount(addressBook);
NSUInteger peopleCounter = 0;
for (peopleCounter = 0;peopleCounter < nPeople; peopleCounter++)
{
ABRecordRef thisPerson = CFArrayGetValueAtIndex(allPeople,peopleCounter);
NSString *contactFirstLast = [NSString stringWithFormat:@"%,%",ABRecordCopyValue(thisPerson, kABPersonFirstNameProperty), ABRecordCopyValue(thisPerson,kABPersonLastNameProperty)];
[names insertObject:contactFirstLast atIndex:peopleCounter];
ABMultiValueRef phoneNumbers = ABRecordCopyValue(thisPerson,kABPersonPhoneProperty);
NSString *firstPhone = (__bridge_transfer NSString*) ABMultiValueCopyValueAtIndex(phoneNumbers, 0);
NSString *secondPhone = (__bridge_transfer NSString*) ABMultiValueCopyValueAtIndex(phoneNumbers, 1);
NSString *thirdPhone = (__bridge_transfer NSString*) ABMultiValueCopyValueAtIndex(phoneNumbers, 2);
[numbers1 insertObject:firstPhone atIndex:peopleCounter];
[numbers2 insertObject:secondPhone atIndex:peopleCounter];
[numbers3 insertObject:thirdPhone atIndex:peopleCounter];
}
}
myView.text=[names componentsJoinedByString:@"\n\n"];
myView.text=[numbers1 componentsJoinedByString:@"\n\n"];
myView.text=[numbers2 componentsJoinedByString:@"\n\n"];
myView.text=[numbers3 componentsJoinedByString:@"\n\n"];
}