Hi,
Thanks for the reply. My question was very vague, I admit.
But now I have moved to your suggestion.
I'm setting up the timer via [NSTimer scheduledTimerWithTimeInterval: 1.0 target: self selector: @selector(doSomething:) userInfo: nil repeats: YES];
But the doSomething is not getting called at all.
May be because this thread is busy doing something else, so do I have to setup the timer in say main Thread. Earlier I was doing so, by setting up the timer by calling this setting up method as [self performSelectorOnMainThread:............], and it was working, but even after invalidating the timer, the timer was still referencing the object that contained NSTimer *timer.

Any suggestions?
Nick

On 22-Oct-2009, at 2:32 PM, Dave Keck wrote:

I'm having a really hard time making sense of you message...

> I have been trying to implement a 1 second repeating timer, but its leading
> to retaining the target object

That's expected behavior - NSTimers retain their targets. The target won't be deallocated until the timer has been invalidated (assuming the timer was the only thing keeping the target alive.)

> But its leading to referencing the target object of my thread, by 3-4 > non-objects (bytes), which shows different descriptions every time as per GC
> Monitor Instrument (kind of undefined behavior).

Woah, this sentence has my completely baffled:

o Prior to this sentence, you were talking about retaining/ releasing, not you're talking about garbage collection. I think I'm still following you though - regardless, the timer is keeping the target alive.

 o 3-4 bytes of what? Why do these bytes matter?

========== Moment of clarity in 3... 2... 1...

Oh. I think you're just trying to have a method called every second. If that's the case, no need to concern yourself with threads and... well, whatever it is that's going on in that code snippet. :D

[NSTimer scheduledTimerWithTimeInterval: 1.0 target: self selector: @selector(doSomething:) userInfo: nil repeats: YES];

That will call self's -doSomething: method every second. Is that what you're trying to accomplish?

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to