NSTimer
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