xcode 将非本地对象的地址传递给 __autoreleasing 参数以进行回写

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8309905/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 22:35:44  来源:igfitidea点击:

Passing address of non-local object to __autoreleasing parameter for write-back

objective-cxcodexcode4.2autorelease

提问by Javier

I'm trying to make app with xcode 4.2 and i'm really confused whay happen this. Could someone help me an explain me why have error in lines when appear &error

我正在尝试使用 xcode 4.2 制作应用程序,我真的很困惑为什么会发生这种情况。有人能帮我解释一下为什么出现 &error 时出现错误

Passing address of non-local object to __autoreleasing parameter for write-back

将非本地对象的地址传递给 __autoreleasing 参数以进行回写

RootViewController.h

根视图控制器.h

RootViewController.m

根视图控制器.m

回答by JeremyP

It would have been easier to diagnose the error without having to guess at the line number on which it occurs, but I thinkthe issue is your use of the error instance variable to pass as the error here:

诊断错误会更容易,而不必猜测它发生的行号,但我认为问题在于您使用错误实例变量在此处作为错误传递:

30    [audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error: &error];

also here

也在这里

49    [fm removeItemAtPath:[recordedTmpFile path] error:&error];

The reason is that, if an error occcurs, in setCategory:error:the existing value of errorwill be overwritten without being released and is thus a potential leak.

原因是,如果发生错误,setCategory:error:现有的值error将被覆盖而不被释放,因此是潜在的泄漏。