NSFetchRequest 自动释放,没有池 - 只是泄漏

发布于 2024-10-12 18:17:57 字数 1608 浏览 6 评论 0原文

首先,我不得不说这个网站及其成员的反应令人惊叹。最有帮助。谢谢。

其次,在对我正在处理的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文