• 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
NSTimer
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTimer


  • Subject: NSTimer
  • From: Bill Allaire <email@hidden>
  • Date: Tue, 3 Apr 2007 15:35:43 -0400

I'm new to Cocoa, so please bear with me.

I initialize a timer when overriding init:
timer = [NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(setDevState:) userInfo:nil repeats:YES];


I create an array to manipulate during each timer event in awakeFromNib:
tableArray = [NSArray arrayWithObjects:aisle1Table, aisle2Table, aisle3Table, nil];
Each object is a NSTableView.


-(void)setDevState:(NSTimer *)aTimer
{
Some calls to Mysql
...
if ([dsdsst compare:@"ONLINE"] == NSOrderedSame)
[[tableArray objectAtIndex: aisle] setBackgroundColor:green]; // Green is NSColor *
else
[[tableArray objectAtIndex: aisle] setBackgroundColor:red]; // Same with red
...
}


In awakeFromNib: I call:
		[self setDevState:timer];

When the program runs, the three tables are colored according to their status (online or offline) as expected. In the debugger the tableArray has a count of three objects. When the timer fires and enters setDevState: the count of tableArray shows and when this object is accessed, GDB is brought up:
{(int)[$VAR count]} objects


If I comment out the line [self setDevState:timer]; and wait for the timer to fire, the debugger is brought up with the same behavior: no count in the array. I don't understand why I can call setDevState: outside a timer and it works fine but when called by way of the timer things go awry.


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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


  • Follow-Ups:
    • Re: NSTimer
      • From: Sherm Pendley <email@hidden>
    • Re: NSTimer
      • From: James Bucanek <email@hidden>
  • Prev by Date: Cocoa "InternetConfig? Need to add a protocol like foo:// and handler app
  • Next by Date: Re: Cocoa "InternetConfig? Need to add a protocol like foo:// and handler app
  • Previous by thread: Re: Cocoa "InternetConfig? Need to add a protocol like foo:// and handler app
  • Next by thread: Re: NSTimer
  • Index(es):
    • Date
    • Thread