I'm trying to build an iphone fitness app to allow the user to first create 1 routine. then within the routine to create exercises, and within each of those exercises to create sets. I'd like to allow the user to create as many sets/routines.
My plan is to create an array within an array within an array.
The first array will hold the exercises (represented by an array). And within the exercise array will be the sets(represented by an array). And finally the set array will actually store the information.
I guess my question is, is this possible? To dynamically create arrays based on the user? I can't seem to find any information on this subject,.
Yes, this is definitely possible: NSArray
and its subclass NSMutableArray
let you create and manage arrays dynamically, growing and shrinking them as needed.
Rather than using arrays of arrays of arrays, I would use special-purpose classes that hold arrays, but hide them, and present some functionality that is related to your specific application.
For example, you may want to consider creating a class for Routine
and for Exercise
. Routine would have methods like
-(void)addExercise:(MyExercise*)exercise;
-(MyExercise)getExerciseForIndex:(int)index;
-(void)removeExerciseAtIndex:(int)index;
and so on, with NSMutableArray
serving as a storage for exercises.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With