0
我有以下代码:从UIActionSheet代表访问视图控制器的变量
@implementation SendMapViewController
NSMutableArray *emails;
在这个方法我创建电子邮件数组和我添加一些NSString的:
- (BOOL) peoplePickerNavigationController: (ABPeoplePickerNavigationController *)peoplePicker
shouldContinueAfterSelectingPerson: (ABRecordRef)person {
ABMultiValueRef emailInfo = ABRecordCopyValue(person, kABPersonEmailProperty);
NSUInteger emailCount = ABMultiValueGetCount(emailInfo);
if (emailCount > 1) {
UIActionSheet *emailsAlert = [[UIActionSheet alloc]
initWithTitle:@"Select an email"
delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
emails = [NSMutableArray arrayWithCapacity: emailCount];
for (NSUInteger i = 0; i < emailCount; i++) {
NSString *emailFromContact = (NSString *)ABMultiValueCopyValueAtIndex(emailInfo, i);
[emails addObject: emailFromContact];
[emailsAlert addButtonWithTitle:emailFromContact];
[emailFromContact release];
}
[emailsAlert addButtonWithTitle:@"Cancel"];
[emailsAlert showInView:self.view];
[emailsAlert release];
}
else {
...
}
CFRelease(emailInfo);
[self dismissModalViewControllerAnimated:YES];
return NO;
}
正如你可以在代码中看到,如果我有多个电子邮件和UIActionSheet。当用户点击代表一个按钮和电子邮件,我想执行以下代码:
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if ([emails count] >= buttonIndex) {
NSString *contactEmail = (NSString *)[emails objectAtIndex:buttonIndex];
...
}
}
但电子邮件阵还没有得到任何电子邮件。我做错了什么?
我正在为iPhone开发。
我认为这是与电子邮件变量相关的事情,它在另一个执行线程中声明(如果您想从另一个不是已创建的执行线程更新接口,则与.NET一样)。 – VansFannel 2010-04-16 10:30:37