Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

Amit Bijlani
Treehouse Guest TeacherForum Contest: iOS Stopwatch App
Edit: This forum contest has ended. See this week's contest:Build a Blog in Ruby on Rails
Hi everybody,
It's time for a new Treehouse Forum contest! First, watch this video to learn more:
After you've watched the video, please read the details below carefully. I'm looking forward to your entries!
How to Enter: Create your iOS Stopwatch app and either upload your code to Github or provide a zipped version of your project via Dropbox or a similar service.
Due Date: All entries must be submitted by July 20th at 11:45pm ET. Here's a timezone chart so you can see what time that is for your locale.
Prize: The entries will be judged by Treehouse teachers based on both design and code. One winner will receive a free month of Treehouse Gold on us! :) We'll announce the winner on July 21st and reveal the next contest.

Amit Bijlani
Treehouse Guest TeacherHi everyone,
I'm very impressed with the quality of all the entries. Some of you really went out there with innovative UI. It's always difficult to pick a winner, because you all did great and these would make for some awesome portfolio additions. I would encourage you to add it to your Github account.
This week's winner is Charlie Hield! Congrats, Charlie! his entry was great all around. The user interface was unique with a nice animation that used Facebook's latest POP framework.
28 Answers

Roel Slüper
3,989 PointsThe due date is in the past, shouldn't it be Juli 20th?

Amit Bijlani
Treehouse Guest TeacherThanks! I've updated it.

Roel Slüper
3,989 PointsTnhx! Here is an update timezone chart

Vlatko .
2,526 PointsOh man, Amit, I still haven't even finished the Crystal Ball app yet!

Markus Reiter
1,123 PointsMe neither. ^^

Ryan Ackermann
14,665 PointsI've been waiting for an iOS forum contest for a while now!! so excited :)

Alex Cevallos
16,551 PointsWould we past the link to our code in the forums?

Amit Bijlani
Treehouse Guest TeacherYes that's exactly what you would do.

Patrick Cooney
12,216 PointsCan we write it in Swift? This seems like the perfect little app for Swift practice.

Stephen Whitfield
16,771 PointsOverachiever. :P

Amit Bijlani
Treehouse Guest TeacherSure, feel free to write it in Swift

Neil Shweky
5,022 PointsWho would I share it with on dropbox?

Amit Bijlani
Treehouse Guest TeacherJust share the link here in the forum

Preston Harris
1,607 PointsWhat kind of methods would we be using to create a stopwatch app. I got all my UI pictures and backgrounds ready, but don't know where to start with the coding. Would NSTimer work, or is something else more appropriate for this?

Neil Shweky
5,022 PointsI think you have to use NSDate... how? I have no idea.

Preston Harris
1,607 PointsNever heard of NSDate, I guess its time to head over to the apple docs.

Neil Shweky
5,022 PointsDoes this help?
"NSDate is a model class. It doesn't fire or do anything except represent a certain date and time. You will have to use both (NSTimer and NSDate) for you stopwatch. When you start the watch save the current date in an NSDate instance and start an NSTimer with a 1 sec interval (or more if you want to display milliseconds). And every time the timer fires, you calculate the difference between the current date and the saved date and show it to the user."

Preston Harris
1,607 PointsThanks a lot!

Amit Bijlani
Treehouse Guest TeacherNSTimer would work well for this app. Apple has a good Introduction to Timers. The documentation covers the various timers available and how you can use them.

faranaway
Courses Plus Student 13,885 PointsCuriously, are you allowed to use CocoaPods?

Amit Bijlani
Treehouse Guest TeacherI don't see why not.

Ben Jakuben
Treehouse TeacherUsing CocoaPods generally only helps. :-D Link for those who haven't used it: http://teamtreehouse.com/library/ios-tools

Preston Harris
1,607 PointsIm having trouble with adding a laps feature to my app. My app looks awesome and works amazing, but it needs that one feature. Can anybody help me out here?

Stephen Whitfield
16,771 PointsMy guess is to have a button that copies the value of the text from your stopwatch label. Every time the user presses the button, they get the value from the time that the button was pressed.

Amit Bijlani
Treehouse Guest TeacherI'm excited to see what everyone comes up with. We have three more days to go in this contest.

Stephen McMillan
iOS Development with Swift Techdegree Graduate 33,994 PointsAdding the final touches to mine Amit Bijlani ! :)

Patrick Cooney
12,216 PointsGah! I know this is a competition but can someone look at my algorithm? I'm going nuts trying to figure out what's wrong. My numbers are compounding when I try to implement the ability to pause. If the first run is 3 seconds and the second run is 2 seconds it shows my total time as 8 seconds. I can't get it to add just the last element of the time array to the previous total. I think my brain is just exhausted.
endTime = Timer().stopTimer()
var nextInterval = Timer().calculateInterval(startTime, end: endTime)
intervals.append(nextInterval)
println("\(intervals)")
for var i=0; i < intervals.count; ++i{
totalTime = totalTime + NSArray(array: intervals).lastObject.doubleValue
}
I've also tried it with a for-in loop

Stephen Whitfield
16,771 Pointsmaybe you should add just the last element in the array.
EDIT: actually i see that you're doing that already. maybe you should set your totalTime to 0 before you implement it in the loop.

Patrick Cooney
12,216 PointsI did that in a part that I didn't show. I think it has to do with the for loop but I don't know what I could be doing wrong.

Patrick Cooney
12,216 PointsTurns out I don't need the loop at all. I attempted to start with a different method than what I ended with in the loop that wouldn't have worked with out the loop. As I was laying in bed it hit me that if the loop is doubling everything but adding the last number correctly, removing it from the loop should keep it from compounding. WIN. It's all gravy from here!

Stephen McMillan
iOS Development with Swift Techdegree Graduate 33,994 PointsHere is the link to my completed Stopwatch App!
Additionally, In the file I've also included my design intentions.
Download from Dropbox -https://www.dropbox.com/s/tlqxb8qsjosbm0j/Simple%20Stopwatch%20iOS%20App.zip
Good luck everyone! :)

Preston Harris
1,607 PointsHey guys, I really need some help on adding laps to my project. This is what i have, but I want it to save the elapsed time, instead of just projecting what my time label say when you push the button. Also, how can put this in a tableview, not a label?
- (IBAction)lapButtonPressed:(id)sender
{
self.lapLabel.text = self.timeLabel.text;
}

Stephen McMillan
iOS Development with Swift Techdegree Graduate 33,994 PointsMaybe you could try adding the elapsed time to an array of elapsed times. Then you could reference that array of times in your tableview. Presumably you would need to use a UITableview instead of UITableViewController, unless your having the elapsed times presented in a different view.
I Included a UITableView in my app to display an array of backgrounds available for the users selection. You can look at mine if your understand it or look here: https://developer.apple.com/library/ios/documentation/uikit/reference/UITableView_Class/Reference/Reference.html

Patrick Cooney
12,216 PointsHere's an article on collection types

Preston Harris
1,607 PointsI'm still a beginner at ios programming, so how would using an array find the elapsed time between the last time the user pressed the lap button?

Stephen McMillan
iOS Development with Swift Techdegree Graduate 33,994 PointsI just tried it in xCode. I'm getting an error. It doesn't like having a double in an array. I'm clueless sorry!

Thomas Nilsen
14,957 PointsHere is stopwatch app. Looking forward to see everyone else's :)
https://www.dropbox.com/s/i3idobzo05ipghr/StopWatchImproved.zip

Björn Steneram
5,523 PointsHere is my stopwatch app, very simple one :)

Preston Harris
1,607 PointsOk guys my app is ALMOST done , except for the laps feature. I don't want to turn it in without it so could anybody offer any last bits of wisdom for me.

Thomas Nilsen
14,957 PointsHave a look at my app. Laps is working like a charm. I don't really like my own solution though, but I started yesterday. It should at the very least point you in the right direction

Preston Harris
1,607 PointsOk I will check it out

Brayden Kness
12,492 PointsI saved the string being displayed and passed it to a table view controller

Brayden Kness
12,492 PointsFinally finished my stopwatch. Enjoy!
Brenden Konnagan
16,858 PointsHere is my submission... :-)
https://www.dropbox.com/s/masgc8cwf67o2bm/Stopwatch%20Concept%20Entry.zip?n=233514913

Tom Diggle
18,679 PointsHere's my stopwatch app https://github.com/tomdiggle/Stopwatch.

Charlie Hield
4,767 PointsHere's my submission.
Brenden Konnagan
16,858 PointsCongrats Charlie!

Ravi Shankar
Courses Plus Student 7,823 PointsCongrats Charlie

Charlie Hield
4,767 PointsThanks everyone! Honestly, didn't expect to win, there were a lot of awesome submissions.

Preston Harris
1,607 Points
Neil Shweky
5,022 PointsMy stopwatch is finally done!!!! Here is the link! https://www.dropbox.com/sh/xv5w8h0fe4iadc3/AAAo5LyJ44GZLaDTgSWP3_wha

Ravi Shankar
Courses Plus Student 7,823 PointsTried this in Swift, here is the link - https://github.com/rshankras/THDemoStopWatch

Ryan Ackermann
14,665 PointsHere's mine, using UIKitDynamics Link To DynamicTime

Neil Shweky
5,022 PointsWhen will the next forum contest be?

Amit Bijlani
Treehouse Guest TeacherThis week's forum contest has already been announced: https://teamtreehouse.com/forum/forum-contest-build-a-blog-in-ruby-on-rails

Neil Shweky
5,022 PointsJust out of curiosity, is there going to be another iOS forum contest in the near future?

jacknoren
24,134 PointsHey everyone. I thought that maybe you can help me. When I download the winners Code to look at it it says the link is broken. I think i need to download something else but I'm honestly not sure. I will copy and paste it so you guys can see it.
ld: library not found for -lPods clang: error: linker command failed with exit code 1 (use -v to see invocation)
If someone could help me that would be really awesome!

Charlie Hield
4,767 PointsDid you download this zip file? Then you'll want to open the Stopwatch.xcworkspace
file in Xcode.

jacknoren
24,134 PointsAwesome! Thank you Charlie.. wow you did a great job on this! Have you been coding before Treehouse?

Charlie Hield
4,767 PointsThanks! Glad you got it to work. Yes, I've been doing it for years. Joined treehouse to learn iOS and have done some other things along the way.
Brenden Konnagan
16,858 PointsBrenden Konnagan
16,858 PointsAmit Bijlani I can't wait to hear your feedback!
I am a huge fan of simplicity and clarity. So that is the route that I took with my Stopwatch concept.
I welcome your thoughts and feedback on the concept.