Variable Scope Problem, iPhone

Posted by Stumf on Stack Overflow See other posts from Stack Overflow or by Stumf
Published on 2010-03-13T02:04:09Z Indexed on 2010/03/13 2:07 UTC
Read the original article Hit count: 440

Filed under:
|
|
|
|

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

© Stack Overflow or respective owner

Related posts about iphone

Related posts about arrays