English 中文(简体)
何时返回?
原标题:retaining when returning?

如果我保留我正在返回的答复。

// METHOD
-(NSData *)dataFromTurbine:(NSString *)pathToURL {

    NSURL *url = [[NSURL alloc] initWithString:pathToURL];
    NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
    NSHTTPURLResponse *response = nil;
    NSError *error = nil;
    NSData *responseData = [NSURLConnection sendSynchronousRequest:request 
                                                 returningResponse:&response 
                                                             error:&error];

    [request release];
    [url release];
    return responseData;
}

// CALLED
NSData *newData = dataFromTurbine(kTurbineDataPath);
[doSomething newData];
最佳回答

由于该方法名称从init 开始,new or copy,dataFromTurbine <>/code>应交还NSData的自动发布。 (Which案现已成为应答案件)

然后,电话方法具有所有权,必要时应当保留。

问题回答

页: 1

从NSURLConnection处获得的NSData物体是自动释放的,因此,只有需要保留/释放。 否则,将自动在下游乐场上释放。





相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。