NSArray can store objects, not primitives, fortunately, the NSNumber class has a convenience method that takes a float primitive and returns a float object as such:
+ (NSNumber *)numberWithFloat:(float)value
so you can fill your array as follows:
float exampleFloat = 5.4; NSArray *anArrayOfFloatObjects = [NSArray arrayWithObjects: [NSNumber numberWithFloat:10.0], [NSNumber numberWithFloat:2], [NSNumber numberWithFloat:4], [NSNumber numberWithFloat:exampleFloat], nil];
As for your specific problem, you can write:
NSMutableArray *tmpArray;
if you use a dictionary to extract matrix values, the only way I can come up with is key code your matrix values ββas such:
A1 A2 A3 A4
B1 B2 B3 B4
C1 C2 C3 C4
D1 D2 D3 D4
eg:
NSMutableDictionary *myDictionary; [myDictionary setObject:[NSNumber numberWithFloat:5.0] forKey:@"A1"]; ... NSNumber *myFloat = [myDictionary objectForKey:@"A1"];
In addition, it is important to indicate that whenever something is written in the @ "something here" format, it is literally an NSString object. so when you write:
NSArray *objectsForArray = [NSArray arrayWithObjects: @"array[tempI][tempJ]", @"array[tempI][tempJ+1]", @"array[tempI][tempJ+2]", nil];
this is the same as spelling:
NSString *newString = @"Roses are red"; // example strings NSString *newString1 = @"Violets are blue"; NSString *newString2 = @"array[tempI][tempJ+1]"; NSString *newString3 = @"These are all string objects"; NSArray *objectsForArray = [NSArray arrayWithObjects: @"array[tempI][tempJ]", newString2, @"array[tempI][tempJ+2]", nil];