2014-09-22 54 views
0
- (void)connectionDidFinishLoading:(NSURLConnection *)connection 
{ 
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ 

    NSError *error = nil; 
    NSString *jsonString = [[NSJSONSerialization JSONObjectWithData:_buffer options:0 error:&error] description]; 

    dispatch_async(dispatch_get_main_queue(), ^{ 

     if (!error) 
     { 
      self.textField.text = jsonString; 
     } 
     else 
     { 
      self.textField.text = [error localizedDescription]; 
     } 

     [self.spinner stopAnimating]; 
     [self.fetchButton setEnabled:YES]; 
     self.connection = nil; 
     self.buffer  = nil; 
    }); 

}); 

}connectionDidFinishLoading示出了的NSString * jsonString線

當我寫該方法然後將其示出了在第五行誤差的誤差。請幫助我我是新的Iphone.Thanks提前。

+0

我假設''&是不是wr在你的實際代碼中如此呢?錯誤說的是什麼? – Stuart 2014-09-22 09:50:44

+0

那我該怎麼辦? – 2014-09-22 09:52:26

+0

你應該告訴我什麼錯誤說... – Stuart 2014-09-22 09:53:17

回答

0

NSString *jsonString = [[NSJSONSerialization JSONObjectWithData:_buffer options:0 error:&error] description]; 

刪除amp;

應該

NSString *jsonString = [[NSJSONSerialization JSONObjectWithData:_buffer options:0 error:&error] description]; 
1

你應該寫這樣的:

NSString *jsonString = [[NSJSONSerialization JSONObjectWithData:_buffer options:0 error:&error] description];