2012-09-14 40 views
0

我想異步調用服務器(ARC酮) - :爲「NSString的」不可見@interface聲明選擇「appendData」

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

當你的錯誤狀態 - 你試圖調用從類的NSString對象appendData方法。由於沒有這樣的方法,你會得到錯誤..檢查內容的類型obj – Stas

+0

你在哪裏宣佈變量「內容」 – AppleDelegate

+0

我已經宣佈它全局像這樣:NSString * content; – clint

回答

4

在接口部分的.h文件中,請聲明如下

NSMutableData *content; 
+0

真棒解決方案;)) – Stas

+0

thnx Gr8答案... – Ayaz

相關問題