iPhone崩溃日志
你解释foollowing崩溃日志......iPhone崩溃日志
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController createAddressBookCopy]: unrecognized selector sent to instance 0x5908300'.
这是什么意思? 我的代码是在这里....
-(NSString *)pathOfFile{
NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
NSString *documentsDirectory=[paths objectAtIndex:0];
//lastName.text=[paths objectAtIndex:0];
return [documentsDirectory stringByAppendingFormat:@"contacts.plist"];
}
-(IBAction)createAddressBookCopy{
UIActionSheet *actionSheet=[[UIActionSheet alloc]
initWithTitle:@"Wanna create a copy of Addressbook?"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:@"Yeah!!!"
otherButtonTitles:nil];
[actionSheet showInView:self.view];
[actionSheet release];
ABAddressBookRef addressBook = ABAddressBookCreate();
CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople(addressBook);
CFIndex nPeople = ABAddressBookGetPersonCount(addressBook);
NSMutableArray *masterList = [[NSMutableArray alloc] init];
for (int i = 0; i < nPeople; i++) {
ABRecordRef ref = CFArrayGetValueAtIndex(allPeople, i);
CFStringRef fName = ABRecordCopyValue(ref, kABPersonFirstNameProperty);
CFStringRef lName = ABRecordCopyValue(ref, kABPersonLastNameProperty);
NSString *contactFirstLast = [NSString stringWithFormat: @"%@", (NSString *)lName];
CFRelease(fName);
CFRelease(lName);
[masterList addObject:contactFirstLast];
//[contactFirstLast release];
}
//self.list = masterList;
[masterList writeToFile:[self pathOfFile] atomically:YES];
[masterList release];
}
//creating action sheet
-(void)actionSheet:(UIActionSheet *) actionSheet willDismissWithButtonIndex:(NSInteger)buttonIndex{
if (buttonIndex!=[actionSheet cancelButtonIndex]) {
UIAlertView *alert=[[UIAlertView alloc]
initWithTitle:@"Copy creaeted."
message:@"New copy is contacts.plist"
delegate:self
cancelButtonTitle:@"DONE"
otherButtonTitles:nil
];
[alert show];
[alert release];
}
}
你发送的消息createAddressBookCopy
到UIViewController
对象。该应用程序崩溃,因为UIViewController
没有该名称的方法。
我的代码在基于视图的应用程序中工作...但是当我使用tabbar时,它会被破坏......为什么? – Shahriar 2011-05-06 09:48:50
这意味着,在你的程序的一些对象要发送createAddressBookCopy
消息UIViewController
,但这UIViewController
对象没有实现这样的方法
是的,我已经给出了代码... – Shahriar 2011-05-06 09:47:07
UIViewController中没有一个叫createAddressBookCopy方法。我怀疑你有一个UIViewController子类,它具有该方法,但出于某种原因,你正在调用超类。如果您使用的是界面构建器,并且没有正确连接网点,则有时会发生这种情况。
你的方法'createAddressBookCopy'有问题。你可以发布你的代码,如何调用和定义方法 – visakh7 2011-05-06 09:44:26