-(IBAction)registerUpdate:(id)sender {
HTTPRequest* request = [[HTTPRequest alloc] initWithUrl:@"http://www.yahoo.com" delegate:self];
[request doRequest];
}
HTTPRequest发出异步请求并调用当前类中的onHTTPResponse方法。
我的问题是我必须发布请求吗?我的猜测是我应该把它变成一个实例变量?
[NSString stringWithFormat:@"Data received: %@", [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]];
我如何释放该字符串对象,还是应该将其分配给变量?
答案 0 :(得分:1)
您使用autorelease
[NSString stringWithFormat:@"Data received: %@", [[[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding] autorelease]]