简体   繁体   English

核心数据详细信息视图出现问题

[英]Trouble with core data detail view

I'm having some trouble with an iPhone app that I'm making. 我正在制作的iPhone应用程序遇到问题。 I have two entities in my xcdatamodel: Team and Camera. 我的xcdatamodel中有两个实体:Team和Camera。 Each Team has a Camera, and every Camera belongs to a Team. 每个团队都有一个摄像机,每个摄像机都属于一个团队。 I have correctly implemented the Team entity into my navigation-based app, so that I can add teams to a table view. 我已经在基于导航的应用程序中正确实现了Team实体,以便可以将团队添加到表视图中。 However, when I go to click on the disclosure button and call the team's Camera entity so I take a picture and store it, my app crashes. 但是,当我单击公开按钮并致电团队的Camera实体,以便我拍照并存储时,我的应用程序崩溃了。

Here's the code from my RootViewController.m that is relevant to Camera entity. 这是我RootViewController.m中与Camera实体相关的代码。

-(void)insertCameraWithTeam:(NSManagedObject *)team picture:(NSString *)picture {
NSManagedObjectContext *context = [self.fetchedResultsController managedObjectContext];
NSManagedObject *camera = [NSEntityDescription insertNewObjectForEntityForName:@"Camera" inManagedObjectContext:context];
[camera setValue:picture forKey:@"picture"];
}


#pragma mark -
#pragma mark Table view data source

- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {
NSManagedObject *team = [self.fetchedResultsController objectAtIndexPath:indexPath];
CameraDetailView *cameraDetailView = [[CameraDetailView alloc] initWithRootController:self team:team];
[self.navigationController presentModalViewController:cameraDetailView animated:YES];
[cameraDetailView release];
}

The "initWithRootController..." is implemented this way in my CameraDetailView.m: 在我的CameraDetailView.m中以这种方式实现了“ initWithRootController ...”:

-(id)initWithRootController:(RootViewController *)aRootController team:(NSManagedObject *)aTeam /*camera:(NSManagedObject *)aCamera*/ {
if ((self = [super init])) {
 self.rootController = aRootController;
 self.team = aTeam;
}
return self;
}

There error occurs when 发生错误时

    - (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {

is called. 叫做。

Does anybody know what I'm doing wrong? 有人知道我在做什么错吗?

I discovered a problem with the links in my NIB file by using a try/catch block. 我通过使用try / catch块发现了NIB文件中链接的问题。 Solution: Always put your code in try/catch blocks first to catch the error! 解决方案:始终先将代码放入try / catch块中,以捕获错误!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM