Use an integer value as part of a variable name
Hello!
I have many UIImageView´s on my MainView named imageView1, imageView2, ...
I can detect which imageView is tapped because of the coordinates.
So I have the number, for example 3, but how can I call something like
Do you have an idea?
Thanks & Regards.
I have many UIImageView´s on my MainView named imageView1, imageView2, ...
I can detect which imageView is tapped because of the coordinates.
So I have the number, for example 3, but how can I call something like
Code:
imageView3.image = [UIImage imageNamed:@"test.png"];
Do you have an idea?
Thanks & Regards.

You call it, by simply… calling it.
Rephrase your question?
Maybe you want an array?
I only have the number:
...
int FIELD = [testController getField:point];
-> now I want to call imageViewFIELD.image = ...
How could I do this?
...
int FIELD = [testController getField:point];
-> now I want to call imageViewFIELD.image = ...
How could I do this?
Yeah you want an array. What you're trying to do isn't possible, though by using an array you can achieve the same result.
Look at the NSArray [developer.apple.com] class reference to get yourself started.
Code:
NSArray * imageViews = ...;
int FIELD = [testController getFieldPoint];
[[imageViews objectAtIndex:FIELD] setImage:...];
Look at the NSArray [developer.apple.com] class reference to get yourself started.
That helps me, thank you very much!
Possibly Related Threads...
Thread: | Author | Replies: | Views: | Last Post | |
Anybody have an idea what this variable is used for? | WhatMeWorry | 8 | 7,120 |
Mar 1, 2007 10:31 AM Last Post: unknown |
|
Converting integer/numeric values to Strings | vnvrymdreglage | 5 | 5,519 |
Oct 23, 2006 07:18 PM Last Post: vnvrymdreglage |
|
fgets is only reading part of the line | Joseph Duchesne | 3 | 4,533 |
Feb 10, 2006 01:23 AM Last Post: Taxxodium |
|
Mathmatical formula for integer checking | Jones | 12 | 10,500 |
Jan 24, 2006 01:58 AM Last Post: zKing |
|
variable frame rate animation in Cocoa | Damian | 3 | 4,900 |
Jul 16, 2003 06:00 PM Last Post: macboy |