我有错误:
[2194:c07] CoreData: error: Failed to call designated initializer on NSManagedObject class 'Event'
2012-12-08 12:00:57.505 eventCost[2194:c07] -[Event setType:]: unrecognized selector sent to instance 0x7456dd0
2012-12-08 12:00:57.523 eventCost[2194:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Event setType:]: unrecognized selector
我的 addEventController:@protocol 有协议
AddEventControllerDelegate
- (void) addEventControllerDidSave:(NSString *) typeText;
- (void) addEventControllerDidCancel:(Event *) personToDelete;
@end
协议的实现:
- (void) addEventControllerDidCancel:(Event *)EventToDelete{
[[self currentPerson] removeEventsObject:EventToDelete];
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void) addEventControllerDidSave:(NSString *)typeText{
Event *newEvent = [[Event alloc]init];
[newEvent setType:typeText];
[currentPerson addEventsObject:newEvent];
[self dismissViewControllerAnimated:YES completion:nil];
}
我也有这个添加新事件的segue:
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if ([[segue identifier]isEqualToString:@"addEvent"])
{
AddEventController *aec = (AddEventController *) [segue destinationViewController];
aec.delegate = self;
}
}
我只是尝试使用 type 属性添加新事件,但我有这个错误,我不明白什么问题..