我在我的项目中成功使用ARC.但是,我遇到了一些文件(例如,在单元测试和模拟对象中),其中ARC的规则现在更加脆弱.我记得听说有一种方法可以在每个文件的基础上禁用ARC,但我无法找到这个选项.
这可能吗?如何基于每个文件禁用ARC?
xcode objective-c automatic-ref-counting manual-retain-release
我正在使用Apple指南中的这个非常简单的代码:
NSMutableData *receivedData;
// Create the request.
NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.apple.com/"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
// create the connection with the request
// and start loading the data
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if (theConnection) {
// Create the NSMutableData to hold the received data.
// receivedData is an instance variable declared elsewhere.
receivedData = [[NSMutableData data] retain];
} else {
// Inform the user that the connection failed.
}
Run Code Online (Sandbox Code Playgroud)
但是对于receivedData = [[NSMutableData data] retain];Xcode 行我给出了一个错误:PushController.m:72:25: ARC forbids explicit …
xcode cocoa memory-management objective-c automatic-ref-counting