开发者

Objective-c when to release objects

-(IBAction)registerUpdate:(id)开发者_StackOverflowsender {
    HTTPRequest* request = [[HTTPRequest alloc] initWithUrl:@"http://www.yahoo.com" delegate:self];
    [request doRequest];
}

The HTTPRequest makes an asynchronous request and calls the onHTTPResponse method in the current class.

My question is do I have to release request? My guess is that I'm supposed to make it an instance variable?

[NSString stringWithFormat:@"Data received: %@", [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]];

How would I release that string object, or should I assign it to a variable?


You release it with autorelease

[NSString stringWithFormat:@"Data received: %@", [[[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding] autorelease]]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜