Hi. I'm writing a Cocoa document-based app (using the Xcode template) that uses a WebView and needs an NSTimer to trigger one of the methods every 10 seconds in the MyDocument class. In my init method, I set up the timer:
@interface MyDocument : NSDocument { IBOutlet WebView *webView; NSTimer *timer; } @implementation MyDocument - (id)init { self = [super init]; if (self) { timer = [NSTimer scheduledTimerWithTimeInterval:10.0 target:self selector:@selector(checkVPN:) userInfo:nil repeats:YES]; [timer retain]; } return self } . . . The timer runs fine and the web view gets initialized and displays webpages properly. Everything is fine until you click a link in the web view, and that particular link happens to open up a new window, which is now a new instance of MyDocument. That new instance of course calls init, and suddenly I have two NSTimers running when I only wanted one timer for the whole app. I'm not sure how to do what I want the right way. I think I need to initialize the timer "further up," to put it lamely. Where should I do this? In main()? Do I need to subclass something that NSDocument is a descendant of? Can anyone point me ot examples of how to do this the right way? I've read the NSRunLoop and NSTimer docs, but I'm still not sure how to fix this. Thanks. -s _______________________________________________ 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 [EMAIL PROTECTED]