Objective-C has nothing of the kind, and overall this is not a very practical way to access data (what if you seal a string? The compiler cannot catch It). I will not intrude on what you really want to do (it will depend on the purpose of this part of your application), but you can use NSMutableDictionary
to get a similar effect:
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init]; for (int i = 0; i < 7; i++) { NSString *key = [NSString stringWithFormat:@"myRectNum & %d", i]; NSValue *value = [NSValue valueWithCGRect:myImageView.bounds]; [dict setObject:value forKey:key]; }
Then to return the values ββback:
NSValue *value = [dict objectForKey:@"myRectNum & 5"]; CGRect bounds = [value CGRectValue]; NSLog(@"height = %f", bounds.size.height);
source share