Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ledd

macrumors newbie
Original poster
Dec 26, 2006
23
0
So I have an application that I have developed in a NSDocument. I want to be able to have it do an update on a timer which I think understand how to implement.

The only problem is I am not familiar with where the NSTimer function would be continuously called every lets say 1 second?

I have a MyDocument.m file which contains my UpdateUI function which is what I would want the NSTimer to call.

And then I also have my main.h file which simply has

Code:
#import <Cocoa/Cocoa.h>

int main(int argc, char *argv[])
{
    return NSApplicationMain(argc, (const char **) argv);
}

Thanks.
 
I apologize for the unnecessary thread I figured it out.

Awesomely enough for those who don't know you can just start the timer from any function call. I don't really know why I thought this would not work. I guess I thought there was maybe a standard that should be upheld to where you should make the NSTimer.
 
I've run into another minor issue that I am struggling with.
So I have a button that I want to change the text of when it is clicked....

So I have...
NSButton* calculate;

So I figured I could do...
[calculate setTitle: @"New Title"];

But this didn't appear to work. Did I do something wrong?
Thanks.
 
How is the button created? Is it an IBOutlet connected in Interface Builder?
 
Yah its an IBOutlet NSButton and then the calculate functions is an IBAction that is connected to the NSButton
 
Ok... lets see if I can appropriately map this out

I have a button in my window... In the InterfaceBuilder I have declared an IBOutlet for the button called stopStartBtn in the Inspector
In my .h I have

Code:
IBOutlet NSButton* stopStartBtn

and a method

Code:
- (IBAction)startStopCounter:(id) sender;

The startStopCounter method is as follows

Code:
- (IBAction)startStopCounter:(id)sender
{	
	if(timer == nil){
		[self startTimer];
		[startStopBtn setTitle: @"Pause"];
	}
	else{
		[self stopTimer];
		[startStopBtn setTitle: @"Start"];
	}
}

The functions startTimer and stopTimer work great but the setTitle change does not create a change...

Hope this outlines the issue better. Thanks.
 
I got it it. It was a bad connection with the .nib file.

Thanks.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.