【发布时间】:2012-08-06 07:13:55
【问题描述】:
我正在使用 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.
}
但是对于receivedData = [[NSMutableData data] retain];这一行,Xcode 给了我一个错误:PushController.m:72:25: ARC forbids explicit message send of 'retain'
如何处理?我正在使用 Xcode 4.4.1
【问题讨论】:
-
这就是Arc right的意义所在,所以你不必保留和释放...
标签: objective-c xcode cocoa memory-management automatic-ref-counting