Note that there are some explanatory texts on larger screens.

plurals
  1. POVariable Scope Problem, iPhone
    text
    copied!<p>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!)</p> <p>I have:</p> <pre><code>NSArray *getValue(NSString *iosearch) { mach_port_t masterPort; CFTypeID propID = (CFTypeID) NULL; unsigned int bufSize; kern_return_t kr = IOMasterPort(MACH_PORT_NULL, &amp;masterPort); if (kr != noErr) return nil; io_registry_entry_t entry = IORegistryGetRootEntry(masterPort); if (entry == MACH_PORT_NULL) return nil; CFTypeRef prop = IORegistryEntrySearchCFProperty(entry, kIODeviceTreePlane, (CFStringRef) iosearch, nil, kIORegistryIterateRecursively); if (!prop) return nil; propID = CFGetTypeID(prop); if (!(propID == CFDataGetTypeID())) { mach_port_deallocate(mach_task_self(), masterPort); return nil; } CFDataRef propData = (CFDataRef) prop; if (!propData) return nil; bufSize = CFDataGetLength(propData); if (!bufSize) return nil; NSString *p1 = [[[NSString alloc] initWithBytes:CFDataGetBytePtr(propData) length:bufSize encoding:1] autorelease]; mach_port_deallocate(mach_task_self(), masterPort); return [p1 componentsSeparatedByString:@"\0"]; } - (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; } </code></pre> <p>I have a tableView set up and want to display my array in it so I then have:</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {............. ......................................................... cell.text = [results objectAtIndex:indexPath.row]; // error results undeclared here return cell; } </code></pre> <p>In my .h file I have:</p> <pre><code>@interface UIDevice_IOKitExtensionsViewController : UIViewController { IBOutlet UITableView *tblSimpleTable; NSArray *results; } @property (nonatomic, retain) NSArray *results; - (NSString *) serialnumber; - (NSString *) backlightlevel; </code></pre> <p>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!</p> <p>Many thanks, Stuart</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload