tags:

views:

145

answers:

2

Hi guys, I am creating my very first iphone app and need help here. My programming background is not C and I am bit lost.

Basically what I want my application to do is to display random bitmaps and let user touch individual bitmap and validate them. The method I used to display the bitmaps is NSTimer with UIImage for the actual bitmaps. So far, it was working fine in displaying the bitmap. But I am stuck on the next step, which is registering the touched bitmaps. I tried to use tag on the bitmap then touchesBegan function. I got a runtime error everytime I touched screen (I think.)

My questions are: 1. Given my requirement, is the method I am using is a good method, or even technically possible? 2. If q#1 answer is no, do you have alternative solution?

Thanks and I appreciate your help!

Regards, Eric

A: 

If you're getting an exception inside your touchesBegan: function, then your code there has a bug in it. If you run your app with the debugger, it should tell you on exactly what line of code the problem is occurring. If I had to guess, I would say that you're trying to send a message to an object which doesn't handle that message, which throws an exception.

Make sure your code is compiling without any warnings -- it's possible you have a typo in a function name somewhere. If you misspell the message name, it will still compile correctly, but it will throw an exception at runtime when you try to send that message.

Adam Rosenfield
Whoa that was fast, thanks.I agree with you that there's something wrong with code inside touchesBegan. I was trying to check the tag of dynamically created image to see if I touched the right thing but apparently it doesn't sit well on runtime. I didn't get any syntax error.
Eric
Also I saw another post in this forum about threading between NSTimer and touchesBegan. Is there another way besides threading?
Eric
A: 

Whoa that was fast, thanks. I agree with you that there's something wrong with code inside touchesBegan. I was trying to check the tag of dynamically created image to see if I touched the right thing but apparently it doesn't sit well on runtime. I didn't get any syntax error. Also I saw another post in this forum about threading between NSTimer and touchesBegan. It says NSTimer won't work with touch functions. Is this true? Is there another way besides threading?

Eric