开发者

how to display array values in Objective-C

sir I'm getting updated values of X,Y,Z from acceleration function and I want to store these values in an array or list. Is there any way kindly suggest.

- (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"开发者_如何学C, @"Z: ", acceleration.z];


You have two options: store one value each in three, corresponding arrays, or create an object to store those three values and create an object at each invocation of your delegate method.

In either case, I'd create an NSMutableArray instance variable to store these in. The second option would be preferable if you're going to be working with these in the future, since you can add more information to the objects, such as timestamps or something.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜