gpt4 book ai didi

iphone - [NSManaged对象名称] : unrecognized selector sent to instance 0x6b77240'

转载 作者:行者123 更新时间:2023-12-03 21:02:43 25 4
gpt4 key购买 nike

Error ::: 2012-11-07 16:07:31.360 Random Date[1100:c07] -[NSManagedObject name]: unrecognized selector sent to instance 0x6b77240 2012-11-07 16:07:31.363 Random Date[1100:c07] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSManagedObject name]: unrecognized selector sent to instance 0x6b77240' * First throw call stack: (0x1793022 0x1193cd6 0x1794cbd 0x16f9ed0 0x16f9cb2 0xed0a57 0xed05e4 0xed00b0 0xecf45d 0xecd2fd 0x316e 0x3481 0xdea1e 0xddfec 0x104f1d 0xef1cb 0x105df1 0x105e0d 0x105ea9 0x446f5 0x4473c 0x234f 0x15386 0x16274 0x25183 0x25c38 0x19634 0x167def5 0x1767195 0x16cbff2 0x16ca8da 0x16c9d84 0x16c9c9b 0x15c65 0x17626 0x1ffd 0x1f65 0x1) terminate called throwing an exception

主要代码如下。

{



RootViewController *rvc = [[RootViewController alloc] init];

UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:rvc];
[[self window] setRootViewController:nc];
[rvc setManagedObjectContext:[self managedObjectContext]];


self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}

在 ROOTVIEWCONTROLLER

enter code here
-(void)addNewRandomDate
{

NSManagedObject *newRandomDate = [NSEntityDescription insertNewObjectForEntityForName:@"RandomDate"
inManagedObjectContext:managedObjectContext];

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setTimeStyle:NSDateFormatterShortStyle];
[dateFormatter setDateFormat:@"EEEE"];

NSDate *date = [NSDate dateWithTimeIntervalSince1970:arc4random()];
NSString *dayName = [dateFormatter stringFromDate:date];

[newRandomDate setValue:date forKey:@"date"];
[newRandomDate setValue:dayName forKey:@"dayName"];

NSError *error = nil;
BOOL success = [managedObjectContext save:&error];
if (!success) {

NSLog(@"Error = %@", error);
}

[self fetchRandomDates];
}

最佳答案

抛出异常的原因是:在 FecthresultControllern 中使用 insertNewObjectForEntityForName:@"RandomDate"inManagedObjectContext:managedObjectContext 而不是使用 enityForname: InManagedObjectContext ...

关于iphone - [NSManaged对象名称] : unrecognized selector sent to instance 0x6b77240',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13274085/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com