2013-02-19 76 views
2
[__NSArrayM relatedObjectDidChange]: unrecognized selector sent to instance 

error Class: NSInvalidArgumentException 

崩溃报告堆栈跟踪:应用程序崩溃:NSInvalidArgumentException

0 CoreFoundation 0x33d153e7 <redacted> + 162 
1 libobjc.A.dylib 0x3ba06963 objc_exception_throw + 30 
2 CoreFoundation 0x33d18f31 <redacted> + 0 
3 CoreFoundation 0x33d1764d <redacted> + 392 
4 CoreFoundation 0x33c6f208 _CF_forwarding_prep_0 + 24 
5 EventKit 0x3440af03 <redacted> + 30 
6 EventKit 0x34410225 <redacted> + 396 
7 EventKit 0x34410095 <redacted> + 28 
8 EventKit 0x3440d3fd <redacted> + 396 
9 Calendar 0x000f10a5 -[createNewEventView editEvent:] + 1696 
10 UIKit 0x35c0f087 <redacted> + 70 
11 UIKit 0x35c0f111 <redacted> + 120 
12 UIKit 0x35c0f087 <redacted> + 70 
13 UIKit 0x35c0f03b <redacted> + 30 
14 UIKit 0x35c0f015 <redacted> + 44 
15 UIKit 0x35c0e8cb <redacted> + 502 
16 UIKit 0x35c0edb9 <redacted> + 488 
17 UIKit 0x35b375f9 <redacted> + 524 
18 UIKit 0x35b248e1 <redacted> + 380 
19 UIKit 0x35b241ef <redacted> + 6198 
20 GraphicsServices 0x3783b5f7 <redacted> + 590 
21 GraphicsServices 0x3783b227 <redacted> + 34 
22 CoreFoundation 0x33cea3e7 <redacted> + 34 
23 CoreFoundation 0x33cea38b <redacted> + 138 
24 CoreFoundation 0x33ce920f <redacted> + 1382 
25 CoreFoundation 0x33c5c23d CFRunLoopRunSpecific + 356 
26 CoreFoundation 0x33c5c0c9 CFRunLoopRunInMode + 104 
27 GraphicsServices 0x3783a33b GSEventRunModal + 74 
28 UIKit 0x35b782b9 UIApplicationMain + 1120 
29 Calendar 0x000a9bbf main + 66 
30 Calendar 0x0003a600 start + 40 

是什么这样的错误意味着,什么是对这种错误的可能性?

我实现editEvent方法:

-(void) editEvent:(EKSpan)span 
{  
    EKEvent * newEditingEvent = self.EventToEdit; 
    CalendarAppDataObject* theDataObject = [self theAppDataObject]; 
    if(eventCalendar != nil && theDataObject.selectedCalendarsForDisplayData != nil){ 

     NSArray *arrayDataUnarchiver =(NSArray *) [NSKeyedUnarchiver unarchiveObjectWithData:theDataObject.selectedCalendarsForDisplayData]; 
     NSMutableSet * uniqueId = [[NSMutableSet alloc ] initWithArray:arrayDataUnarchiver]; 
     [uniqueId addObject:eventCalendar.calendarIdentifier]; 

     NSArray * selectedCal = [uniqueId allObjects]; 

     NSData *arrayDataArchiver = [NSKeyedArchiver archivedDataWithRootObject:selectedCal]; 
     theDataObject.selectedCalendarsForDisplayData = arrayDataArchiver; 
     //save selected to database 

     NSError *error; 
     self.managedObjectContext = theDataObject.managedObjectContext; 
     NSManagedObjectContext *context = [self managedObjectContext]; 
     // **** log objects currently in database **** 
     // create fetch object, this objects fetch's the objects out of the database 
     NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; 
     NSEntityDescription *entity = [NSEntityDescription entityForName:@"Settings" inManagedObjectContext:context]; 
     [fetchRequest setEntity:entity]; 


     NSArray *fetchedObjects= [context executeFetchRequest:fetchRequest error:&error] ; 
     for (NSManagedObject *info in fetchedObjects) 
     { 
      [info setValue:arrayDataArchiver forKey:@"selectedCalendarsForDisplayData"] ; 
     } 

     //this is for comitting changes to core data 
     [context save:&error]; 
     [fetchRequest release]; 
     [uniqueId release]; 
    } 


    NSString * eventNotesString = @""; 
    if(self.eventNotes != nil) 
    { 
     eventNotesString = self.eventNotes; 
    } 
    newEditingEvent.notes = [EventsDataUtil generateEventsNoteForSavingColor:eventNotesString colorToSave:self.eventBackColor]; 


    if(self.eventRecurrenceRule != nil) 
    { 
     NSArray * RecRulesArray = [[[NSArray alloc ] initWithObjects:self.eventRecurrenceRule, nil]autorelease]; 

     if(theDataObject.isRepeatChanged) 
     { 
      [newEditingEvent setRecurrenceRules:RecRulesArray]; 
     } 

    }else 
    { 
     [newEditingEvent setRecurrenceRules:nil]; 
    } 

    if([[ self.eventTitle stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] isEqualToString:@""]) 
    { 
     self.eventTitle = @"New Event"; 

    } 
    newEditingEvent.title = self.eventTitle; 
    if(isLocationPhoneNumber) 
    { 
     NSString * PhoneLocationString = @"tel:"; 
     PhoneLocationString = [PhoneLocationString stringByAppendingFormat:@"%@", [self.contactPhoneNumber stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]]; 
     newEditingEvent.location = PhoneLocationString; 
    } 
    else 
    { 
     newEditingEvent.location = self.eventLocation; 
    } 


    newEditingEvent.startDate = self.eventStartDate; 
    newEditingEvent.endDate =self.eventEndDate; 
    newEditingEvent.allDay = self.eventAllDay; 
    newEditingEvent.calendar = self.eventCalendar; 
    newEditingEvent.URL = self.eventURL; 
    // repeat and alert 
    NSArray * Alarms = nil; 
    if(self.eventAlert !=nil) 
    { 
     if(self.eventSecondAlert !=nil) 
     { 
      Alarms = [[[NSArray alloc] initWithObjects:self.eventAlert,self.eventSecondAlert, nil]autorelease]; 
     } 
     else { 
      Alarms = [[[NSArray alloc] initWithObjects:self.eventAlert, nil]autorelease]; 
     } 

    } 

    newEditingEvent.alarms = Alarms; 


    NSError *err; 
    [newEditingEvent setCalendar:self.eventCalendar]; 
    [sharedEventStore saveEvent:newEditingEvent span:span commit:YES error:&err]; 
    theDataObject.needUpdate = YES; 
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) 
    { 
     [[NSNotificationCenter defaultCenter] postNotificationName:@"dismissEventDetails" object:nil]; 
    } 
    else{ 

     [self dismissViewControllerAnimated:YES completion:NULL]; 
    } 


} 
+0

+1用于添加堆栈跟踪。尽管请花更多时间格式化它。 – trojanfoe 2013-02-19 10:28:45

+0

它什么时候崩溃?在执行与EventKit相关的特定操作时?你可能传递了非法的论点。你在使用ARC吗? – Resh32 2013-02-19 10:31:03

+0

是当试图保存日历事件对象时,我不使用ARC – 2013-02-19 10:32:16

回答

0

错误报告告诉你,你需要知道的一切:即开即NSArray类没有一个叫relatedObjectDidChange方法

[__NSArrayM relatedObjectDidChange]: unrecognized selector sent to instance 

,所以您的代码显然称为某处:

[someArray relatedObjectDidChange]; 

没有看到您的代码,我无法提供更多帮助。我想看看这个方法:

[createNewEventView editEvent:] 

而该类

+0

我没有实现方法“relatedObjectDidChange” – 2013-02-19 10:29:43

+0

@MohammadRabi请在我的回答中显示我已经注明的代码。 – trojanfoe 2013-02-19 10:33:42

+0

请检查我的问题。我已经编辑它并添加你要求的代码 – 2013-02-19 10:37:31

0

方法relatedObjectDidChange发送到NSArray类的一个对象,它的类不响应的定义。你有没有把NSMutableArrayNSArray混在一起?

或者是relatedObjectDidChange您确实在自己的某个对象上实现了自己的方法吗?在这种情况下,您可能会将NSArray分配给您期望成为自己班级的变量。

+0

我没有实现方法“relatedObjectDidChange” – 2013-02-19 10:31:14