2012-01-08 5 views
0

xcode 4.2.1을 ios5와 함께 설치하면 json을 사용하려고합니다.json ios5 화면에 아무것도 표시되지 않습니다.

이 내 코드

나의 NSLog(@"array %@",jsonArray); 내가 모든 기록을 볼 수 있습니다, 모든 것이 괜찮에서
-(void)start 

{ 
    responseData = [[NSMutableData data]retain]; 
    membreArray = [NSMutableArray array]; 
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http:******.php"]]; 
    [[NSURLConnection alloc] initWithRequest:request delegate:self]; 

} 
-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response 
{ 
    [responseData setLength:0]; 
} 

-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data 
{ 
    [responseData appendData:data]; 
} 

-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error 
{ 
    NSLog(@"error %@",error); 
} 

-(void)connectionDidFinishLoading:(NSURLConnection *)connection 
{ 
    [connection release]; 

    NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; 

    [responseData release]; 

    jsonArray = [responseString JSONValue]; 

    NSLog(@"array %@",jsonArray); 



} 

. 하지만 내 tableview 화면에서 아무것도.

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
    return [jsonArray count]; 
} 

// Customize the appearance of table view cells. 
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier = @"Cell"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; 
     cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 
    } 

    // Configure the cell. 

    NSDictionary *dico = [self.jsonArray objectAtIndex:indexPath.row]; 
    cell.textLabel.text = [dico objectForKey:@"name"]; 


    return cell; 
} 

이 코드 엑스 코드 3에서 작동하지만 엑스 코드 4

으로는 SOMES하시기 바랍니다 도움이됩니다.

답변

0

데이터로드를 마친 후에는 다시로드하도록 tableview에 지시해야합니다. 나는 당신의 코드에서 그것을 볼 수 없습니다. 이런 식으로 뭔가를 시도 :

-(void)connectionDidFinishLoading:(NSURLConnection *)connection 
{ 
    [connection release]; 

    NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; 

    [responseData release]; 

    jsonArray = [responseString JSONValue]; 

    NSLog(@"array %@",jsonArray); 
    /* This tells your tableView to reload */ 
    [tableView reloadData]; 
} 

을 또한, 당신의 TableView가 IBOutlet를 통해 디자이너로 연결되어 있는지 확인하십시오. 그렇지 않으면 귀하의 reloadData 명령은 청각 장애인 귀에 해당합니다.

관련 문제