• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSTimer problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTimer problem


  • Subject: Re: NSTimer problem
  • From: Keary Suska <email@hidden>
  • Date: Wed, 16 Jan 2008 17:55:01 -0700
  • Thread-topic: NSTimer problem

on 1/16/08 3:22 PM, email@hidden purportedly said:

You are leaking objects like mad.

>     timer = [[NSTimer alloc] initWithFireDate:[NSDate
> dateWithTimeIntervalSinceNow:currentInterval]
>                                      interval:currentInterval target:self

You *do* know that above you are setting your object property, and not a
local variable?

> -(void)setTimer:(NSTimer*)tm{
>
>     [timer autorelease];
>     timer = [tm retain];
> }

Here you are retaining an alloced object after autoreleasing it, so it will
never be released. If you don't know why, re-read the "cocoa memory
management guidelines" (again?).

This will probably not solve your problem. It is likely that the problem
lies in code that you aren't showing, such as how the timer is being created
in the first place.

Also:

> Stepping through the debugger, I see that when inside my invalidate
> function, the timer is null, 0x0.

It always will, the first time. Once it has been created, it should no
longer be null.

Best,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

References: 
 >NSTimer problem (From: email@hidden)

  • Prev by Date: Re: Scroll view clip view not moving to new object inserted in contained NSCollectionView - when are resizing events in the view hierarchy complete?
  • Next by Date: Re: NSTableView: tableView:objectValueForTableColumn:row called more than necessary when scrolling
  • Previous by thread: NSTimer problem
  • Next by thread: Re: NSTimer problem
  • Index(es):
    • Date
    • Thread