- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { //NSLog(@"Array: %@",rows); return [rows count];// AT THIS LINE }
Program received signal: “EXC_BAD_ACCESS”
THANKS FOR THE REPLY Actually I have attached it to the WebPage By NSUrl where I have made a PHP array and I have created a NSLOG where I am getting the Values in the array form but When It exceute the line return [rows count];. It gives error when I am writting statically return 2; then it execute. I am explaining you what I am doing . I am initialising the NIb with Name tableViewController=[[JsonTestViewController alloc] initWithNibName:@"JsonTestViewController" bundle:nil]; In JsonTestViewController.m I have this code
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { //NSLog(@"Array: %@",rows); return [rows 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] autorelease]; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; }
// Configure the cell. NSDictionary *dict = [rows objectAtIndex: indexPath.row]; NSString *strlb1=[dict objectForKey:@"block"]; NSString *strlb2=[dict objectForKey:@"name"]; strlb1=[strlb1 stringByAppendingString:@" , "]; strlb1=[strlb1 stringByAppendingString:strlb2]; NSString *str1=@"FPS : "; NSString *str2=[dict objectForKey:@"p_hours"]; NSString *strpinf; if([str2 isEqualToString:@"FP"]) { strpinf=@"Free Parking"; } else if([str2 isEqualToString:@"12"]) { strpinf=@"2 hours"; } else if([str2 isEqualToString:@"14"]) { strpinf=@"4 hours"; } else if([str2 isEqualToString:@"MP"]) { strpinf=@"Metered Parking"; } str1=[str1 stringByAppendingString:strpinf]; cell.textLabel.text =strlb1; cell.detailTextLabel.text = str1;
return cell; }
(void)viewDidLoad {
[super viewDidLoad]; NSURL *url = [NSURL URLWithString:@"SITE URL"]; NSString *jsonreturn = [[NSString alloc] initWithContentsOfURL:url];
NSData *jsonData = [jsonreturn dataUsingEncoding:NSUTF32BigEndianStringEncoding]; NSError *error = nil;
NSDictionary * dict = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&error]; if (dict) { rows = [dict objectForKey:@"users"]; }
NSLog(@"Array: %@",rows); [jsonreturn release]; }
(void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use. }
(void)viewDidUnload { // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; }
(void)dealloc { [super dealloc]; }
@end