Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Mac Programming / October 2005



Tip: Looking for answers? Try searching our database.

A simple clock

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
deepstar@gmail.com - 31 Oct 2005 17:42 GMT
I'm trying to create a simple clock and have this code so far:

- (void)awakeFromNib {
scheduler = [NSTimer scheduledTimreWithInterval:1.0
target:self
selector:@selector(timeCheck:)
userInfo:nil
repeats:YES];
[scheduler retain];
{

- (void) timeCheck :(NSTimer *)aTimerl
{
[scheduler invalidate];
[scheduelr release];
scheduler = nil;
[showTime setStringValue:scheduler];
}

But I get this error message "NSTimer discarding exception 'Invalid
parameter not satisfying: aString !=nil". Am I far off target or have I
just gotten the timeCheck function wrong? (I suspect that that's the
culprit). I have tried reading through the Apple documentation for both
NSTimer and NSCalendarDate but they are hard to grasp since they use
too general concepts.
deepstar@gmail.com - 31 Oct 2005 17:51 GMT
I just realised that I had a mistake in the timeCheck function, the
revised version now looks like

- (void) timeCheck :(NSTimer *)aTimerl
{
NSCalendarDate *myTime = [NSCalendarDate now];
[scheduler invalidate];
[scheduelr release];
scheduler = nil;
[showTime setStringValue:myTime];
}

The error message I get now is: NSTimer discarding exception '***
+[NSCalendarDate now]: selector not recognized' that raised during
firing of timer with target 3486a0 and selector 'timecheck:'. This
error is displayed once every second so I guess the that at least
NSTimer method is working properly.
Tom Harrington - 31 Oct 2005 18:51 GMT
> I just realised that I had a mistake in the timeCheck function, the
> revised version now looks like
[quoted text clipped - 13 lines]
> error is displayed once every second so I guess the that at least
> NSTimer method is working properly.

The error message is pretty clear.  NSCalendarDate does not have a
method called +now, so you're getting an exception when you try to call
it.

Signature

Tom "Tom" Harrington
Macaroni, Automated System Maintenance for Mac OS X.
Version 2.0:  Delocalize, Repair Permissions, lots more.
See http://www.atomicbird.com/

deepstar@gmail.com - 31 Oct 2005 19:07 GMT
Well your comment made me take another look at the code and I instantly
saw that NSCalendarDate *myTime = [NSCalendarDate now]; should be

NSCalendarDate *myTime = [NSCalendarDate date];

Now that that's fixed I don't receive any more error messages but the
textfield won't update! I really hate to bug you guys about small
problems like this one but it has been boggling me for over three days
now.
Tom Harrington - 31 Oct 2005 19:52 GMT
> Well your comment made me take another look at the code and I instantly
> saw that NSCalendarDate *myTime = [NSCalendarDate now]; should be
[quoted text clipped - 5 lines]
> problems like this one but it has been boggling me for over three days
> now.

Maybe it's because you invalidate your timer after the first time it
fires?  You tell it to repeat when you create it, but then you prevent
it from actually doing so.

Signature

Tom "Tom" Harrington
Macaroni, Automated System Maintenance for Mac OS X.
Version 2.0:  Delocalize, Repair Permissions, lots more.
See http://www.atomicbird.com/

deepstar@gmail.com - 31 Oct 2005 20:02 GMT
Tom Harrington skrev:

> > Well your comment made me take another look at the code and I instantly
> > saw that NSCalendarDate *myTime = [NSCalendarDate now]; should be
[quoted text clipped - 15 lines]
> Version 2.0:  Delocalize, Repair Permissions, lots more.
> See http://www.atomicbird.com/

That seems to have solved the problem Tom, thanks for walking me
through it. I plan to put all of my current and future projects on a
Cocoa site for newbies so you've probably helped more people than you
think!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.