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하시기 바랍니다 도움이됩니다.