views:

71

answers:

1

I have a grid of UIImageViews. The images names come from a sqlite3 database. When the user selects an image, I need to call a method which will set that image as the preferred one.

But to do this, this method must receive the id of the image in the database. Now, I have really no idea how I could achieve that a click on a specific UIImageView in the grid will call that method, and give the id as parameter.

Lets say I have this method:

  • (void)makeImageAsDefault:(NSInteger)imageID { .... }

In InterfaceBuilder I have no chance to give the right parameter to the action method when an touch up event occurs. I guess I have to do something programatically here.

On the web, I would have created an URL that takes the parameter. How is something like this done on iPhone-OS?

+2  A: 

you could simply use the tag property of the uiimageview object and set the imageId to it.

if you specify and touched up event you can reference the sender (which is the uiimageview object) get the tag from the object and do whatever you want with it.

that's the most easy way i guess. if you need the tag property for something else you can always subclass the uiimageview and add extra property's to it ( which also would be the clean and proper way to do it)

Andy Jacobs
Thanks! I found that subclassing is the solution to the problem.
Thanks