Variable Scope Problem, iPhone
- by Stumf
Hello all,
I need some help here so I will do my best to explain. I have worked on this all day and had no success (just learning!)
I have:
NSArray *getValue(NSString *iosearch)
{ .................................
................................... \\ More code here
}
- (NSString *) serialnumber
{
NSArray *results = getValue(@"serial-number");
if (results) return [results objectAtIndex:0];
return nil;
}
- (NSString *) backlightlevel
{
NSArray *results = getValue(@"backlight-level");
if (results) return [results objectAtIndex:0];
return nil;
}
I have a tableView set up and want to display my array in it so I then have:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {.............
.........................................................
cell.text = [results objectAtIndex:indexPath.row]; // error results undeclared here
return cell;
}
The problem is I get results undeclared as indicated above. I also can't figure how I could get serialnumber and backlightlevel to display on the click of a button or even at load. My attempts have thrown back errors like error: 'serialnumber' undeclared (first use in this function) and warnings like warning: 'return' with a value, in function returning void. Sorry for the long question!
Many thanks,
Stuart