开发者

iPhone crash log

开发者 https://www.devze.com 2023-03-04 14:27 出处:网络
do you explain the foollowing crash log...... Terminating app due to uncaught exception \'NSInvalidArgumentException\', reason: \'-[UIViewController createAddressBookCopy]: unrecognized selector sent

do you explain the foollowing crash log......

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController createAddressBookCopy]: unrecognized selector sent to instance 0x5908300'.

what does it mean? my code is here....

-(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 = [[开发者_如何学GoNSMutableArray 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];
    }
}


Check if your IBAction is connected properly. I think its not connected properly. Check if the declaration of the method in .h file is same.


You have sent the message createAddressBookCopy to a UIViewController object. The app crashed because UIViewController does not have a method of that name.


It means that you have some code that tried to call the createAddressBookCopy method on a UIViewController instance. According to the documentation, no such method exists, hence the crash.


That means that some object in your program trying to send createAddressBookCopy message to UIViewController, but this UIViewController object doesn't implement such method


UIViewController doesn't have a method called createAddressBookCopy. I suspect you have a UIViewController subclass which does have that method, but for some reason you're calling the super class. This sometimes happens if you're using interface builder and don't have your outlets hooked up correctly.

0

精彩评论

暂无评论...
验证码 换一张
取 消