storing retrieveing Uint64 data
-
I'm trying to capture a time using suggestions from list users :
UInt64 startTime = UnsignedWideToUInt64(AbsoluteToNanoseconds(UpTime()));
I'd like to store the caputred times in an array object and retrieve them later for calculating reaction times to an onscreen display.
I've tried using:
UInt64 startTime = UnsignedWideToUInt64(AbsoluteToNanoseconds(UpTime()));
printf (" \n\nstart time %llu ", startTime); //checking value
pass ++;
printf ("at pass = %d\n\n", pass); //tracking iteration through method
[nextButtonPressed insertObject: [NSNumber numberWithUnsignedLongLong: startTime] atIndex:pass]; //hopefully putting value into array
NSLog(@"\nafter storage starttime is %llu\n\n",[[nextButtonPressed objectAtIndex:pass] longLongUnsignedValue]); //checking value to compare to original
The log output looks like this:
start time 73580042471882 at pass = 1
2006-12-26 08:16:43.544 WordView[5736]
after storage starttime is 4294967296
The value that I think I am storing is not the one that I am retrieveing. Can anyone help me understand what is going on?
Also, should I be using NSArrayController. I discovered it with all its nifty actions, but i can't get it to instantiate and I haven't locate any documentation about it. If I should use it, where can I find some references that discuse how to use it?
thanks,
Julia -
On Dec 26, 2006, at 8:25 AM, julia Cline wrote:
> Also, should I be using NSArrayController. I discovered it with<http://www.google.com/search?rls=en-us&q=NSArrayController>
> all its nifty actions, but i can't get it to instantiate and I
> haven't locate any documentation about it. If I should use it,
> where can I find some references that discuse how to use it?
>
mmalc -
On Dec 26, 2006, at 18:25, julia Cline wrote:
> UInt64 startTime = UnsignedWideToUInt64(AbsoluteToNanoseconds(UpTime
> ()));
> printf (" \n\nstart time %llu ", startTime); //checking value
> pass ++;
> printf ("at pass = %d\n\n", pass); //tracking iteration through
> method
> [nextButtonPressed insertObject: [NSNumber
> numberWithUnsignedLongLong: startTime] atIndex:pass]; //hopefully
> putting value into array
Hopefully ? :-)
The way to append values to an array is addObject: and not
insertObject:. I guess that you can remove the "pass" temporary if
you use addObject.
Read file:///Developer/ADC%20Reference%20Library/documentation/Cocoa/
Conceptual/Collections/index.html
Are you sure that "nextButtonPressed" is a proper name for a
collection of timestamps?
> NSLog(@"\nafter storage starttime is %llu\n\n",[[nextButtonPressed
> objectAtIndex:pass] longLongUnsignedValue]); //checking value to
> compare to original
>
> The log output looks like this:
>
> start time 73580042471882 at pass = 1
>
> 2006-12-26 08:16:43.544 WordView[5736]
> after storage starttime is 4294967296
Maybe its difference between printf and NSLog formatting?
This is an easier and more correct way to check:
UInt64 nano = UnsignedWideToUInt64(AbsoluteToNanoseconds(UpTime
()));
NSNumber *nanoNumber = [NSNumber numberWithUnsignedLongLong:nano];
assert(nano == [nanoNumber unsignedLongLongValue]);
Best Regards,
Nir Soffer



