1

我正在尝试异步调用服务器(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'

有人可以建议我哪里错了吗?

4

1 回答 1

5

在接口部分的 .h 文件中,请声明以下内容

NSMutableData *content;
于 2012-09-14T06:50:03.387 回答