i have another problem this time, i’m fetching json codes that will be used to populate the tableview i have in my xib so, to start with my .h file
@interface FirstViewController : UIViewController<UITableViewDelegate, UITableViewDataSource, ASIHTTPRequestDelegate> {
NSMutableArray *resultArray;
IBOutlet UITableView *thetableView;
NSMutableData *responseData;
}
@property (nonatomic,retain) NSArray *arrayTypes;
@property (nonatomic,retain) NSMutableArray *resultArray;
@property (nonatomic,retain) IBOutlet UITableView *thetableView;
in my .m file i implemented this
- (void) viewDidLoad{
responseData = [[NSMutableData data]retain];
NSURL *url = [NSURL URLWithString:@"http://localhost/fetch.php"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[[NSURLConnection alloc] initWithRequest:request delegate:self];
[super viewDidLoad];
[self.thetableView reloadData];
}
in the connectiondidfinishloading:
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
[connection release];
NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
[responseData release];
NSLog(@"%@", responseString);
NSDictionary *dictionary = [responseString JSONValue];
NSMutableArray *response = [dictionary valueForKey:@"itemn"];
resultArray = [[NSArray alloc] initWithArray:response];
}
and now the problem, the tableview has implemented both the numberofrowsinsection and didselectrowatindextpath methods but the latter is never called as the size of the array is 0 and even reloading, it doesn’t work am i missing something or is there a similar tutorial to follow? sorry for the length just hoping the infos will be useful
you should reload tableview once you have the complete data..see the updated code