Warning: file_put_contents(/datas/wwwroot/jiajiahui/core/caches/caches_template/2/default/show.php): failed to open stream: Permission denied in /datas/wwwroot/jiajiahui/core/libraries/classes/template_cache.class.php on line 55

Warning: chmod(): Operation not permitted in /datas/wwwroot/jiajiahui/core/libraries/classes/template_cache.class.php on line 56
iPhone崩溃日志 - 源码之家

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]; 
    } 
} 
+0

你的方法'createAddressBookCopy'有问题。你可以发布你的代码,如何调用和定义方法 – visakh7 2011-05-06 09:44:26

检查您的IBAction是否连接正确。我认为它没有正确连接。检查.h文件中的方法声明是否相同。

+0

是否有基于视图和基于tabbar的应用程序之间的连接有任何区别? – Shahriar 2011-05-06 09:54:11

+0

如何在视图控制器的.h文件中声明这种方法,以及如何连接它们? – visakh7 2011-05-06 09:55:33

+0

- (NSString *)pathOfFile; - (IBAction)createAddressBookCopy; – Shahriar 2011-05-06 09:58:06

你发送的消息createAddressBookCopyUIViewController对象。该应用程序崩溃,因为UIViewController没有该名称的方法。

+0

我的代码在基于视图的应用程序中工作...但是当我使用tabbar时,它会被破坏......为什么? – Shahriar 2011-05-06 09:48:50

这意味着你有一些代码试图在UIViewController实例上调用createAddressBookCopy方法。根据documentation,没有这样的方法存在,因此崩溃。

这意味着,在你的程序的一些对象要发送createAddressBookCopy消息UIViewController,但这UIViewController对象没有实现这样的方法

+0

是的,我已经给出了代码... – Shahriar 2011-05-06 09:47:07

UIViewController中没有一个叫createAddressBookCopy方法。我怀疑你有一个UIViewController子类,它具有该方法,但出于某种原因,你正在调用超类。如果您使用的是界面构建器,并且没有正确连接网点,则有时会发生这种情况。