FROM : Justin Giboney
DATE : Tue Apr 22 21:34:14 2008
I am trying to put a automatic date and time field into my GUI.
I have a text field connected to a variable called "theDateTime" in my
controller class. If I set the variable manually the text field works
just fine. But I want it to update automatically. My code is attached.
Thank you
Justin Giboney
#import "Controller.h"
@implementation Controller
- (id) init {
[super init];
[NSThread detachNewThreadSelector:@selector(runClock) toTarget: self
withObject: nil];
return self;
}
- (void) setDateTime {
NSAutoreleasePool *tempPool = [[NSAutoreleasePool alloc] init];
theDateTime = [NSDate date];
[tempPool release];
}
- (void) runClock {
bool keepRunning = true;
do {
// sleep the specified time
usleep(5000000);
[self setDateTime];
} while (keepRunning == true);
}
@end
DATE : Tue Apr 22 21:34:14 2008
I am trying to put a automatic date and time field into my GUI.
I have a text field connected to a variable called "theDateTime" in my
controller class. If I set the variable manually the text field works
just fine. But I want it to update automatically. My code is attached.
Thank you
Justin Giboney
#import "Controller.h"
@implementation Controller
- (id) init {
[super init];
[NSThread detachNewThreadSelector:@selector(runClock) toTarget: self
withObject: nil];
return self;
}
- (void) setDateTime {
NSAutoreleasePool *tempPool = [[NSAutoreleasePool alloc] init];
theDateTime = [NSDate date];
[tempPool release];
}
- (void) runClock {
bool keepRunning = true;
do {
// sleep the specified time
usleep(5000000);
[self setDateTime];
} while (keepRunning == true);
}
@end
| Related mails | Author | Date |
|---|---|---|
| Justin Giboney | Apr 22, 21:34 | |
| Shawn Erickson | Apr 22, 22:34 | |
| Shawn Erickson | Apr 22, 22:41 | |
| Justin Giboney | Apr 23, 00:24 | |
| Shawn Erickson | Apr 23, 00:47 |






Cocoa mail archive

