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

rd42

macrumors newbie
Original poster
Mar 6, 2010
6
0
I'm looking for clues, pointers (no pun), and search term suggestions on where to start looking for a way to record accelerometer data to a csv file and possibly email/ftp it out. I'm new to Obj C so I'm not quite sure where to start.

I found this simple accelerometer tutorial that displays the data I want to record.
http://www.switchonthecode.com/tutorials/iphone-tutorial-reading-the-accelerometer

In MainViewController.m starting at line 44 I found this:

Code:
- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration {
  labelX.text = [NSString stringWithFormat:@"%@%f", @"X: ", acceleration.x];
  labelY.text = [NSString stringWithFormat:@"%@%f", @"Y: ", acceleration.y];
  labelZ.text = [NSString stringWithFormat:@"%@%f", @"Z: ", acceleration.z];
  
  self.progressX.progress = ABS(acceleration.x);
  self.progressY.progress = ABS(acceleration.y);
  self.progressZ.progress = ABS(acceleration.z);
}

I'm guessing that somewhere in that method I could capture the accelerometer data and write to a file.

Thanks for any ideas,

Robert
 
Cocoa/Objective C uses the delegation model quite a lot — where one object nominates itself to receive reports from another. What you'll do to read the accelerometer is write a class that acts as a delegate to receive accelerometer reports. The method you've found is the one that receives the reports, from an Apple-supplied class called UIAccelerometer.

Probably the easiest thing to allow reporting is to keep a mutable string and append accelerometer status to it. Add a button to post an email and when the user taps it, use MessageUI to bring up an email dialogue. For security reasons, there's no provided method to send an email silently.

For simplicity, it's probably fine to just chuck all this functionality into the application delegate for now.
 
Thanks, I just discovered the mail challenge.

I'll check ou NSMutableString, thanks!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.