Я могу анализировать данные и просматривать вывод, но я не могу отобразить их в табличном представлении
проблема в том, что 1-й код моего просмотра таблиц выполняется, а остальные функции работают, поэтому я получаю 0, как избежать этого
это мой код
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
NSLog(@" value %d",[jsonArray count]);// always 0
return [jsonArray count];
}
в этом методе также я получаю 0 значение
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath
*)indexPath { NSDictionary *aTweet = [jsonArray objectAtIndex:[indexPath
row]]; NSLog(@ " divy is
%@",aTweet);// nothing
}
другие коды
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
[connection release];
NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
[responseData release];
NSError *error;
SBJSON *json = [[SBJSON new] autorelease];
NSDictionary *data = (NSDictionary *) [json objectWithString:responseString error:nil];
NSDictionary *menu = (NSDictionary *) [data objectForKey:@"name"];
//label.text=[dict objectForKey:@"firstName"];
// parsing all the items in to the NSArray
NSArray *items = (NSArray *) [menu objectForKey:@"phoneNumber"];
int ndx;
//NSDictionary *stream;
for (ndx = 0; ndx< items.count; ndx++) {
stream = (NSDictionary *)[items objectAtIndex:ndx];
NSLog(@"This is the title of a stream: %@", [stream valueForKey:@"type"]);
[jsonArray addObject:stream];
}
NSLog(@" aray is %@",jsonArray);// show all data working
NSLog(@" sterab is %@",[stream valueForKey:@"home"]);// this is also working
и это мой взгляд действительно загрузил ()
- (void)viewDidLoad {
jsonArray= [[NSMutableArray alloc] init] ;
[super viewDidLoad];
responseData = [[NSMutableData data] retain];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://Json/Number.json"]];
[[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 {
label.text = [NSString stringWithFormat:@"Connection failed: %@", [error description]];
}