Note that there are some explanatory texts on larger screens.

plurals
  1. POFrozen uptime on iOS / iPhone
    primarykey
    data
    text
    <p>Would someone know why I'm experiencing weird uptime with the following method?</p> <pre><code>NSProcessInfo *processInfo = [NSProcessInfo processInfo]; NSTimeInterval systemUptime = [processInfo systemUptime]; </code></pre> <p>For first minutes, everything seems fine, but when I come back on the app hours or days laters the uptime is still the same : 30min, or 1h34... it seems to freeze at a random moment. Mostly on iPhone 4 (rarely on Simulator or iPad)</p> <p>It could be linked to my way of showing it:</p> <pre><code>+ (NSTimeInterval)uptime:(NSNumber **)days hours:(NSNumber **)hours mins:(NSNumber **)mins { NSProcessInfo *processInfo = [NSProcessInfo processInfo]; //START UPTIME/////// NSTimeInterval systemUptime = [processInfo systemUptime]; // Get the system calendar NSCalendar *sysCalendar = [NSCalendar currentCalendar]; // Create the NSDates NSDate *date = [[NSDate alloc] initWithTimeIntervalSinceNow:(0-systemUptime)]; unsigned int unitFlags = NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit; NSDateComponents *c = [sysCalendar components:unitFlags fromDate:date toDate:[NSDate date] options:0]; //NSString *uptimeString = [NSString stringWithFormat:@"%dd %dh %dmin", [c day],[c hour],[c minute]]; *days = [NSNumber numberWithInt:[c day]]; *hours = [NSNumber numberWithInt:[c hour]]; *mins = [NSNumber numberWithInt:[c minute]]; [date release]; //END UPTIME//////// return systemUptime; } </code></pre> <p>And later in the code:</p> <pre><code>NSNumber *uptimeDays, *uptimeHours, *uptimeMins; [CJGDevice uptime:&amp;uptimeDays hours:&amp;uptimeHours mins:&amp;uptimeMins]; NSString *uptimeString = [NSString stringWithFormat:@"%@d %@h %@min", [uptimeDays stringValue], [uptimeHours stringValue], [uptimeMins stringValue]]; </code></pre> <p>EDIT: after 3 days recording the results on iPad and iPhone I can see that this uptime is wrong, the time is running too slowly, the more we wait the more it's obvious that it's late</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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