Iphone [NSManagedObject IsequalString:]:发送到实例0x454a590'的无法识别的选择器;
我得到了上面的错误,不知道它发生在哪里。有没有办法调试它。我已经放进了一些断点,但它没有中止,它没有中止那些区域 代码如下:Iphone [NSManagedObject IsequalString:]:发送到实例0x454a590'的无法识别的选择器;,iphone,xcode,core-data,Iphone,Xcode,Core Data,我得到了上面的错误,不知道它发生在哪里。有没有办法调试它。我已经放进了一些断点,但它没有中止,它没有中止那些区域 代码如下: -(void)viewDidLoad { if (managedObjectContext == nil) { managedObjectContext = [(NewWorkoutViewController *)[[UIApplication sharedApplication] delegate]
-(void)viewDidLoad
{
if (managedObjectContext == nil)
{
managedObjectContext = [(NewWorkoutViewController *)[[UIApplication sharedApplication] delegate] managedObjectContext];
NSLog(@"After managedObjectContext: %@", managedObjectContext);
}
//Setup PickerView values.
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
CGAffineTransform transform = CGAffineTransformMakeTranslation(0, 480);
pickerView.transform = transform;
[UIView commitAnimations];
// When the view loads, run this action.
[super viewDidLoad]; // This NEEDS to be here or the application will not work!
route.delegate = self;
//Initialise variable.
counterInt = 0;
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch;
touch=[touches anyObject];
CGPoint point=[touch locationInView:self.view];
if (CGRectContainsPoint([route frame],point))
{
[self routePickerShow];
}
if (CGRectContainsPoint([activity frame],point))
{
[self activityPickerShow];
}
if (CGRectContainsPoint([intensity frame],point))
{
[self intensityPickerShow];
}
}
-(IBAction)routePickerShow
{
NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Route" inManagedObjectContext:managedObjectContext];
[request setEntity:entity];
NSError *error = nil;
NSArray *results = [managedObjectContext executeFetchRequest:request error:&error];
// Check for errors from the FetchRequest
if (nil == results || nil != error)
NSLog(@"Error getting results : %@", error);
routeArray = [results mutableCopy];
[request release];
int arrayItemQuantity = [routeArray count];
NSLog(@"Array Quantity: %d", arrayItemQuantity);
int i;
for (i = 0; i < arrayItemQuantity; i++)
{
NSLog(@"Element %i: %@", i, [[routeArray objectAtIndex:i] valueForKey:@"route_name"]);
NSLog(@"Element %i: %@", i, [[routeArray objectAtIndex:i] valueForKey:@"route_id"]);
}
// Initialise PickerView details.
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
CGAffineTransform transform = CGAffineTransformMakeTranslation(0, 200);
pickerView.transform = transform;
[self.view addSubview:pickerView];
[UIView commitAnimations];
}
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)routePicker
{
return 1;
}
-(NSInteger)pickerView:(UIPickerView *)routePicker numberOfRowsInComponent:(NSInteger)component
{
return [routeArray count];
}
-(NSString *)pickerView:(UIPickerView *)routePicker titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
return [routeArray objectAtIndex:row];
}
-(void)pickerView:(UIPickerView *)routePicker didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
route.text = [[routeArray objectAtIndex:row] valueForKey:@"route_name"];
mapID = [[routeArray objectAtIndex:row] valueForKey:@"route_id"];
NSLog(@"Map ID NW: %@", mapID);
//activity.text = [list objectAtIndex:row];
//intensity.text = [list objectAtIndex:row];
}
-(void)viewDidLoad
{
if(managedObjectContext==nil)
{
managedObjectContext=[(NewWorkoutViewController*)[[UIApplication sharedApplication]委托]managedObjectContext];
NSLog(@“在managedObjectContext之后:%@”,managedObjectContext);
}
//设置PickerView值。
[UIView beginAnimations:nil上下文:nil];
[UIView setAnimationDuration:1.0];
CGAffineTransform transform=CGAffineTransformMakeTransform(0480);
pickerView.transform=转换;
[UIView委员会];
//加载视图时,运行此操作。
[super viewDidLoad];//必须在此处,否则应用程序将无法工作!
route.delegate=self;
//初始化变量。
countint=0;
}
-(无效)触摸开始:(NSSet*)触摸事件:(UIEvent*)事件
{
UITouch*触摸;
touch=[触摸任何对象];
CGPoint=[触摸位置视图:self.view];
if(CGRectContainsPoint([route frame],point))
{
[自选节目];
}
if(CGRectContainsPoint([activity frame],point))
{
[自我活动示范];
}
if(CGRectContainsPoint([强度帧],点))
{
[自我展示];
}
}
-(IBAction)路线图
{
NSFetchRequest*request=[[NSFetchRequest alloc]init];
NSEntityDescription*entity=[NSEntityDescription entityForName:@“路由”在managedObjectContext:managedObjectContext中];
[请求集合实体:实体];
n错误*错误=nil;
NSArray*结果=[managedObjectContext executeFetchRequest:请求错误:&错误];
//检查FetchRequest中的错误
if(nil==结果| | nil!=错误)
NSLog(@“获取结果时出错:%@”,错误);
routeArray=[results mutableCopy];
[请求释放];
int arrayItemQuantity=[routeArray计数];
NSLog(@“数组数量:%d”,arrayItemQuantity);
int i;
对于(i=0;i
我所知道的是,它没有得到方法pickerView的支持,它在这之前终止。您的具体错误是您有一个字符串,您正试图设置为核心数据对象。路由id是对象还是字符串?mapID是字符串吗?可能是这一行:
NSLog(@"Element %i: %@", i, [[routeArray objectAtIndex:i] valueForKey:@"route_id"]);
此外,您可能希望添加一个断点来捕获未捕获的异常。打开断点窗口。选择“全局断点”组,这样您只需执行一次,所有项目中都会执行该操作。将objc_exception_throw添加到断点,您将在异常崩溃代码之前捕获所有异常。另外,在调试代码中启用NSZombies。有关某些信息,请参阅和。路由id是一个对象,mapID是一个字符串。我注释掉了这一部分中的所有代码,只插入了一个NSLog语句,但仍然得到了相同的错误。如果mapID是字符串,而route_id是NSManagedObject,那么这一行:`mapID=[[routeArray objectAtIndex:row]valueForKey:@“route_id”];`当运行时尝试从托管对象获取字符串值时,将导致该错误。但是你把它说出来了。单步执行时运行的最后一行代码是什么?您是否设置了objc_异常_抛出断点?调用堆栈被命中时是什么样子的?Don,我刚刚意识到您指的是-(iAction)routePickerShow中的代码行。这类特定代码工作正常,详细信息显示在控制台中。是的,我设置了objc_exception_throw断点。如何检查调用堆栈,我不太熟悉调试器。这有什么意义吗:0x94feb4e6 mov 0x8(%ebp),%esiYes,那是我的哑巴-%%将使用
说明
,当然NSManagedObject具有该属性。pickerView中应该显示什么?如果是route_id,则可能需要显示NSString表示形式。