我试图异步调用服务器(ARC -on):
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:request delegate:self];
if (theConnection) {
content = [NSMutableData data];
NSLog(@"responseData from setup.php: %@", content);
} else {
// Inform the user that the connection failed.
NSLog(@"error from server response in set up");
}
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
NSLog(@"connection did receive response");
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[content appendData:data];
NSLog(@"connection did receive data");
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSLog(@"connection did finish load");
NSLog(@"Succeeded! Received %@ bytes of data",receivedData);
}
但我在从服务器获取内容时遇到问题: - 在didReceiveData函数中,出现以下错误: - 'NSString'没有可见的@interface声明选择器'appendData'
有人可以告诉我哪里可能出错吗?
答案 0 :(得分:5)
在接口部分的.h文件中,请声明以下内容
NSMutableData *content;