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

Drew017

macrumors 65816
Original poster
May 29, 2011
1,254
11
East coast, USA
Hello- I'm trying to make a window that simply displays the time and date in Cocoa. However, I just can't figure out how to do it! here's what I have so far...

Can anyone help? Thanks! :)

I'm using Xcode 3.1.4...
 

Attachments

  • MyClock 2.zip
    52.8 KB · Views: 133
Hello- I'm trying to make a window that simply displays the time and date in Cocoa. However, I just can't figure out how to do it! here's what I have so far...

Do it step by step.

1. Create a window with a text field that displays let's say "21:10:05, 29 Jan 2012".

2. Change your code so that the text field displays the time and date when you application is started.

3. Change your code so that the text field changes its display every second.

After looking at your project, maybe you should look for tutorials at developer.apple.com first.
 
Here you go. Now, look up NSTimer and make it update every second. And then look up drawing graphics and draw minute/hour hands.
 

Attachments

  • Clock.zip
    29.8 KB · Views: 172
Take a look at the source code files, it should be pretty straightforward. Add a text field to your window and connect it to the 'timeOutput' delegate.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.