对于“NSString的”不可见@interface声明选择“appendData” [关闭](No

2019-10-17 05:39发布

我想打电话给服务器异步(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”

任何人都可以给我建议,我可能是错的?

Answer 1:

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

NSMutableData *content;


文章来源: No visible @interface for 'NSString' declares the selector 'appendData' [closed]