User970008 User970008 - 5 months ago 17
Objective-C Question

Convert NSTimer to NSUInterval for Array Index

I want to use a NSTimer count to get a corresponding Index position from a sub array.

-(void)someMethod: (NSTimer*)t{

NSUInteger *tickNumber = (NSUInteger)t;
NSMutableArray *subArray = [dataPoints objectAtIndex:tickNumber];

//etc...
}


I get the warnings:


"Incompatible integer to point conversion initializing NSUInteger
(unsigned long)


How can I use the NSTimer interval to pull out data from a subarray index?

EDIT:
I misunderstood how the properties of the NSTimer worked. I thought that I could more easily access the current interval of the timer. Instead, I now just use my own internal integer in the loop.

NSUInteger frameTicker =0;

-(void)someMethod: (NSTimer*)t{
frameTicker++;
NSMutableArray *subArray = [dataPoints objectAtIndex:frameTicker];

}


No conversion is necessary.

Answer

As per @EmilioPelaez I did not use NSTimer directly:

NSUInteger frameTicker =0;
-(void)someMethod: (NSTimer*)t{
 frameTicker++;
 NSMutableArray *subArray = [dataPoints objectAtIndex:frameTicker];

 }

I would give him credit, but he did not post an answer.