Xcode 4 Analytics 未检测到内存泄漏情况

发布于 2024-11-19 03:25:46 字数 703 浏览 4 评论 0原文

我的 iOS 应用程序中有这段代码:

- (IBAction)cameraButtonPressed:(id)sender
{
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera] == NO)
    {
        return;
    }

    UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
    cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera;
    cameraUI.allowsEditing = NO;
    cameraUI.delegate = self;
    [self presentModalViewController:cameraUI animated:YES];
}

这段代码的问题是方法末尾需要有一个 [cameraUI release]; 。过去,Xcode 内置的静态代码分析器帮助我发现了这些疏忽,但在我当前安装的 Xcode 4.0.2 中,它没有发现这个问题。我尝试重新启动 Xcode,并尝试清理构建文件夹(在单击“项目”菜单时按住选项),但没有成功。最新的 Xcode 中的分析器是否有问题,或者我还遗漏了什么?

I have this code in my iOS app:

- (IBAction)cameraButtonPressed:(id)sender
{
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera] == NO)
    {
        return;
    }

    UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
    cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera;
    cameraUI.allowsEditing = NO;
    cameraUI.delegate = self;
    [self presentModalViewController:cameraUI animated:YES];
}

The problem with this code is that there needs to be a [cameraUI release]; at the end of the method. In the past, the static code analyzer built into Xcode has helped me catch these oversights, but with my current Xcode 4.0.2 install, it does not find this problem. I have tried to restart Xcode, and tried the Clean Build Folder (holding down option while clicking the Project menu), and have had no luck. Is there a problem with the analyzer in the newest Xcode, or is there something else I am missing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

往日情怀 2024-11-26 03:25:46

您应该在 UIImagePickerControllerDelegate 回调方法中释放 picker

You should release the picker in the UIImagePickerControllerDelegate callback methods.

你的他你的她 2024-11-26 03:25:46

过去的静态代码分析器
内置于 Xcode 帮助我抓住了
这些疏忽,但以我目前的
Xcode 4.0.2安装,没有找到
这个问题。

鉴于 John Boker 的回答,您可能不再关心,但如果这确实是一个问题,您可以通过从 http://clang-analyzer.llvm.org/release_notes.html,并告诉 Xcode 将其与set-xcode-analyzer 命令(http://clang-analyzer.llvm .org/xcode.html)。

In the past, the static code analyzer
built into Xcode has helped me catch
these oversights, but with my current
Xcode 4.0.2 install, it does not find
this problem.

You may no longer care, given John Boker’s answer, but if this was genuinely a problem, you can use an older (or newer) version of the Clang static analyzer by downloading it from http://clang-analyzer.llvm.org/release_notes.html, and telling Xcode to use it with the set-xcode-analyzer command (http://clang-analyzer.llvm.org/xcode.html).

意犹 2024-11-26 03:25:46

表示

UIImagePickerController 是自动释放的对象,   UIImagePickerController *cameraUI = [[[UIImagePickerController alloc] init]autorelease];

UIImagePickerController is autoreleased object presenting that

    UIImagePickerController *cameraUI = [[[UIImagePickerController alloc] init]autorelease];

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文