i have an array of some values that i use in a mathematical formula, and i want to know which is the better data structure(NSArray or NSDictionary or …) to use? Thanks.

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Any reason for not using NS(Mutable)Dictionary (NSNumber/NSString) as key / value?
You can try some thing like this:
XYPair:NSObject<NSCoding,NSCopying>{
NSNumber *xValue;
NSNumber *yValue;
}
let the initializer be some thing like,
-(id) initWithXValue:(NSNumber*)x YValue:(NSNumber)y;Usage:
XYPair *someEntry = [XYPair alloc] initWithXValue:[NSNumber numberWithInt:1000] YValue:[NSNumber numberWithInt:0.25]];NSMutableDictionary *ds = [NSMutableDictionary alloc] initWithObjects:someEntry,@"1",nil];
Dont forget to implement NSCoding (requried for archiving),NSCopying(in order to qualify to be a valid key) for XYPair