// Name: src/cocoa/timer.mm
// Purpose: wxTimer for wxCocoa
// Author: Ryan Norton
-// Modified by:
+// Modified by: David Elliott
// Created: 2005-02-04
// RCS-ID: $Id$
// Copyright: (c) Ryan Norton
wxTimer* m_timer;
}
-- (id)setTimer:(wxTimer*)theTimer;
+- (id)init;
+- (id)initWithWxTimer:(wxTimer*)theTimer;
- (wxTimer*)timer;
@end // interface wxNSTimerData : NSObject
@implementation wxNSTimerData : NSObject
-- (id)setTimer:(wxTimer*)theTimer;
+- (id)init
{
+ if(!(self = [super init]))
+ return nil;
+ m_timer = NULL;
+ return self;
+}
+
+- (id)initWithWxTimer:(wxTimer*)theTimer;
+{
+ if(!(self = [super init]))
+ return nil;
m_timer = theTimer;
return self;
}
+
- (wxTimer*)timer
{
return m_timer;
wxAutoNSAutoreleasePool thePool;
+ wxNSTimerData *userInfo = [[wxNSTimerData alloc] initWithWxTimer:this];
m_cocoaNSTimer = [[NSTimer
scheduledTimerWithTimeInterval: millisecs / 1000.0 //seconds
target: wxTimer::sm_cocoaDelegate
selector: @selector(onNotify:)
- userInfo: [[wxNSTimerData alloc] setTimer:this]
+ userInfo: userInfo
repeats: oneShot == false] retain];
+ [userInfo release];
return IsRunning();
}
{
if (m_cocoaNSTimer)
{
- NSObject* theUserInfo = [m_cocoaNSTimer userInfo];
+ // FIXME: Is this safe to do if !isValid ?
[m_cocoaNSTimer invalidate];
- [theUserInfo release];
[m_cocoaNSTimer release];
m_cocoaNSTimer = NULL;
}