NSFetchRequest 自动释放,没有池 - 只是泄漏
首先,我不得不说这个网站及其成员的反应令人惊叹。最有帮助。谢谢。
其次,在对我正在处理的 iPhone/iPad 应用程序进行故障排除时,我正在对以下错误进行故障排除:
NSFetchRequest autoreleased with no pool in place - just Leaking.
罪魁祸首代码似乎可以
NSFetchRequest *request = [[NSFetchRequest alloc] init];
这种方法中找到
-(NSArray *)searchDatabase:(int)uniqueID withPredicate:(NSString *)pred{
NSLog(@": DetailViewController/searchDatabase() method...executing. ");
NSLog(@": DetailViewController/searchDatabase() pred = %@",pred); // returns ParentID
NSError *error = nil;
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Directory" inManagedObjectContext:self.managedObjectContext];
//: moved above line
NSPredicate *predicate = [NSPredicate predicateWithFormat:[NSString stringWithFormat:@"%@=%@", pred, [NSNumber numberWithInt:uniqueID]]];
NSFetchRequest *request = [[NSFetchRequest alloc] init];
[request setReturnsObjectsAsFaults:NO];
[request setEntity:entity];
[request setPredicate:predicate];
//: get the session and update the record with the time it ended
NSArray *mutableFetchResults = [self.managedObjectContext executeFetchRequest:request error:&error];
NSLog(@": DetailViewController/searchDatabase() mutableFetchResults = %@",mutableFetchResults);
[request release];
[error release];
NSLog(@": DetailViewController/searchDatabase() method...terminating.");
return mutableFetchResults;
}
在我的 我不确定发布语句是否正确设置,但即使如此,我仍然不确定错误是否首先出现。我对 Objective C 有点陌生,在编译时应用程序没有指示任何错误(该消息在运行时显示)。
如果有人能帮助我解决这个问题,我将不胜感激。
谢谢
爱德华
First off I have to say this website and its members are amazing in their responses. Most helpful. thank you.
Secondly, I am troubleshooting the following error while troubleshooting an iPhone/iPad app that I am working on:
NSFetchRequest autoreleased with no pool in place - just leaking.
the culprit code seems to be
NSFetchRequest *request = [[NSFetchRequest alloc] init];
found in this method
-(NSArray *)searchDatabase:(int)uniqueID withPredicate:(NSString *)pred{
NSLog(@": DetailViewController/searchDatabase() method...executing. ");
NSLog(@": DetailViewController/searchDatabase() pred = %@",pred); // returns ParentID
NSError *error = nil;
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Directory" inManagedObjectContext:self.managedObjectContext];
//: moved above line
NSPredicate *predicate = [NSPredicate predicateWithFormat:[NSString stringWithFormat:@"%@=%@", pred, [NSNumber numberWithInt:uniqueID]]];
NSFetchRequest *request = [[NSFetchRequest alloc] init];
[request setReturnsObjectsAsFaults:NO];
[request setEntity:entity];
[request setPredicate:predicate];
//: get the session and update the record with the time it ended
NSArray *mutableFetchResults = [self.managedObjectContext executeFetchRequest:request error:&error];
NSLog(@": DetailViewController/searchDatabase() mutableFetchResults = %@",mutableFetchResults);
[request release];
[error release];
NSLog(@": DetailViewController/searchDatabase() method...terminating.");
return mutableFetchResults;
}
I am not sure if the release statements are properly set up, but even still I am unsure while the error shows up in the first place. I am a little new to objective c, and at compile time the application did not indicate any errors (the message shows up at runtime).
If anyone can help me out with this, it would be most appreciated.
thanks
Edward
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论