xcode “NSString”没有可见的@interface 声明了选择器“appendData”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12418715/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
No visible @interface for 'NSString' declares the selector 'appendData'
提问by clint
I am trying to call the server asynchronously (ARC -on):
我正在尝试异步调用服务器(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);
}
But i am having problem getting the content from the server:- in didReceiveData function, following error is coming:- No visible @interface for 'NSString' declares the selector 'appendData'
但是我在从服务器获取内容时遇到问题:- 在 didReceiveData 函数中,出现了以下错误:- 没有可见的 @interface for 'NSString' 声明了选择器 'appendData'
Can anybody suggest me where I could be wrong?
任何人都可以建议我哪里可能出错?
回答by AppleDelegate
in your .h file in the interface section please declare the following
在接口部分的 .h 文件中,请声明以下内容
NSMutableData *content;