Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

kurkah

macrumors newbie
Original poster
Apr 22, 2010
10
0
U.K.
Hi guys,

Just working on a project using the iPhone accelerometer, i seem to be struggling with a simple prob..
I am basically storing the accelerometer values into an array using a button. I am doing this several times (but all stored in SAME array).

I then have a method that checks every value with its proceeding value
e.g
if the first reading was 10 4 6 9
this method would check 10 with 4, 4 with 6 and 6 with 9.

So far this is fine, but if the accelerometer data is saved several times..
e.g. first reading = 10, 4, 6, 9
second reading = 7, 5, 2, 8

What i wanted the method to do is compare the values in the first reading then compare the values in the second reading. but the method is comparing every value with its proceeding one since all the values are in the same array.

How would i overcome this pro.

cheers in advance::
 
You do know that the accelerometer output consists of 3 values for the X Y and Z components of acceleration, right?
B

Yes i am aware of the accelerometer's capability. But i am only working with the X readings for now..

The acceleration.x readings are casted into integers and saved in a stroreArray, In a button press the values are saved, when the button is pressed again different set of values are saved...

I have this code in the method i am trying to compare the values from the accelerometer reading.

Code:
.
.
int value=0;
for (int i=0;i<storeArray; i++) {		
{
if ([[storeArray objectAtIndex:i] intValue] == x && [[storeArray objectAtIndex:i+1] intValue] == y) 
	{		
		value++;
	}
[array2 replaceObjectAtIndex:position withObject:[NSNumber numberWithFloat:value]];					

}
 
storeArray is of type NSMutableArray* ? Then why do you loop on the condition "i<storeArray"?
 
Don't assume we can read your mind.

The details of how you pull the accelerometer data out, cast it and stuff it in storeArrayay be where the problem lies.

As the last post shows you need to give us more context. How is storeArray declared?

B
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.