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 trialAmit Bijlani
Treehouse Guest TeacherForum Contest: Tic-Tac-Toe App for iOS
It's time for another Treehouse Forum contest! This one is for all the iOS students:
After you've watched the video, please read the details below carefully. We're looking forward to your entries!
Game Rules:
This is a simple Tic-Tac-Toe app also known as Noughts & Crosses. Imagine you are playing this on a piece of paper with a friend. Where each of you gets to add an X or a 0 on a 3x3 grid. The player who succeeds in placing three consecutive Xs or 0s in a horizontal, vertical, or diagonal row wins the game.
How to Enter:
Create your app as a native app iOS app. Then post a link as an answer to this post. It can be a link to downloadable project files, a GitHub repo. Be creative with the design and user experience! If you want to learn iOS then checkout the iOS Development Track.
Due Date:
All entries must be submitted by March 23th 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 Pro (formerly called "Gold") on us! We'll announce the winner on March 24th and reveal the next contest.
Blake Gall
2,517 Pointsaawwwww. I'd accept but I don't have an apple computer so I cant get xcode. but I have made a few simple games in html (A Little Bit Too Simple!)
Jo Albright
5,199 PointsHey Amit, what do you think about making a contest where multiple people come together to work on a project through GitHub. I would love to see how well group projects workout with people who have never met each other and in a short amount of time.
Amit Bijlani
Treehouse Guest TeacherThere were so many amazing entries. You should all be proud but there can be only one winner and this week it is Jo Albright! Who went above and beyond what was required. I also want to mention that I loved Tom Bakker's design. Great job!
I would encourage everyone to upload their entry to Github if you haven't already done so. Github is like having a resume for a developer. It shows potential employers your capabilities.
Jon Kroeker
24,649 PointsCongrats [Jo Albright](teamtreehouse.com/joalbright)! Great designs from everyone! Thanks Amit for the contest, it's great to get this practice building our own apps outside of the learning modules. I look forward to more contests!
Jo Albright
5,199 PointsI am very humbled and appreciative of this experience, especially from being surrounded by everyone's amazing ideas and designs. This is how I feel.
Tom Bakker
2,132 PointsThank you very much Amit! This really does mean a lot to me. And I want to congratulate Jo Albright on winning, you really knocked this one out of the park! Also everyone else that contributed to this contest, it's amazing to see what people can come up with in such a short period of time.
Hope there will be another iOS contest soon!
Enara L. Otaegi
13,107 PointsI should say congrats Jo Albright, even after you made me lose concentration for five minutes with those gifs :D You deserve it. Great job!
Jo Albright
5,199 PointsThank you. And yes, I wasted about that amount of time on that site as well.
Enara L. Otaegi and others on here that don't have social or web links on your profiles. I would love to see what things you all are doing now and in the future.
Enara L. Otaegi
13,107 PointsYou're right! Profile updated. Not a lot to show yet. But I added my Twitter username and Linkedin profile (not in English, sorry I have to update that) just in case anyone wants to make a treehouse study group or something like that.
agreatdaytocode
24,757 PointsCongrats Jo! I hope you push this one into the app store! :)
Jo Albright
5,199 PointsThanks Aaron! I have it submitted... currently waiting for review :)
Thanks Enara. I put up links to force myself to do more public code and projects... it gives me the drive to finish side/personal projects to show off. Keep it up! Study group is a great idea.
Stephen Whitfield
16,771 PointsStudy group? I am in. Paired Programming or group projects would be an amazing experience too. Tons to learn from that. LinkedIn and Twitter (although it really gets not much use) will be added to my profile.
agreatdaytocode
24,757 PointsGroup + Code = Sign this guy up! I'll add you guys on twitter if thats the road we are going to take.
Holger Liesegang
50,595 PointsSounds great :)
Naomi Freeman
Treehouse Guest TeacherJo Albright Congrats :) May I please ask how you started? In terms of this app. What was the first thing that you approached? I'm still pretty new to this and am just trying to wrap my head around it. With a calculator, I understand: you need to make stuff do math. Cool.
But with a game, where did you begin?
I made an in-road, but it looks like this: https://github.com/summerspirit/Matchy-matchy Aha * this is not the animation you're looking for *
Jo Albright
5,199 Points@Naomi Freeman - Great question. You have inspired me to write a blog post about why I did what I did and how I went about it. I will add an update on here when I have finished it.
Holger Liesegang
50,595 PointsHi Naomi Freeman ,
I hope your MAMP is running ok now? There where some forum problems while answering your question then and I just wanted to be sure :)
Jo Albright
5,199 PointsNaomi Freeman - Here is my blog post on game creation. Hopefully you will get something out of my explanation, that will help you gain a vision for your own games. Also, I hope to find time to better document my public app code.
Naomi Freeman
Treehouse Guest TeacherJo Albright Thanks :) Much appreciated.
39 Answers
Greg L Gomez
11,913 Points- "Noughts & Crosses" =)
Amit Bijlani
Treehouse Guest TeacherUpdated! Thanks :)
Henry Moran
10,516 PointsThis is really cool. I hope that by next time when an iOS contest takes place I'll be ready. Good luck everyone! Please continue to do these contest for iOS – maybe once a month?
Danny Finkelstein
2,947 Pointshttps://teamtreehouse.com/forum/teamtreehouse.com/tracks/ios-development link is not accessible :/
Amit Bijlani
Treehouse Guest TeacherI've updated it. Thanks!
Anthony Lockett
24,266 Pointsit still isn't accessible :/
Amyr Haq
9,001 PointsTry this: iOS Development Track
Danny Finkelstein
2,947 PointsThank You :)
Matthew Mascioni
20,444 PointsAwesome! Good luck to everyone!
MD.MAHEDI HASAN PRINCE
1,287 PointsIf you please clear me about where i should put my project zip file link . i will be very happy . good luck everyone .
qvwzucovkm
8,080 Points"...Then post a link as an answer to this post. It can be a link to downloadable project file..."
MD.MAHEDI HASAN PRINCE
1,287 Pointsthanks jorge . it's very kind of you . :)
qvwzucovkm
8,080 PointsCheers. Let's do our best!
saad
26,165 PointsCan't wait to get started! :-)
Thomas Nilsen
14,957 PointsI got a working version. Now comes the hard part. Clean up the code and make a cool design :)
Stephen Whitfield
16,771 PointsI absolutely hate the latter, but I love adding effects.
Thomas Nilsen
14,957 Pointshttps://www.dropbox.com/s/bqahgfs1rdf5w9x/Tic%20Tac%20Toe.zip
Good luck to everyone!
Amit Bijlani
Treehouse Guest TeacherGreat job!
Enara L. Otaegi
13,107 PointsHere is my entry. Good luck everybody!
Amit Bijlani
Treehouse Guest TeacherI like that you can play against the system. Great work!
Stephen Whitfield
16,771 PointsSame implementation I was going to use - user vs. computer. Great stuff!
Enara L. Otaegi
13,107 PointsThank you!
Jo Albright
5,199 PointsHere is my Tic Tac Toe rendition.
Options
- Game Mode : tap the top right button to change the game mode
- Play against a person or robot (robot has semi-decent AI to give you a challenge)
- The robot will always be green
- View Stats : tap the top left button to view stats
- View Past Games : swipe up and down to view all games played
Features
- First player color switches each game allowing a fair advantage to winning.
- A label stating which color's turn it is.
- A label stating who won on past games.
- Turning on a robot when it is green's turn to play, automatically starts the robot playing.
- Built-in delay for robot to make it look like it is thinking of a move.
- Big banner to congratulate the winner.
- New button appears after a win (or if you swipe up and back again) to play a new game.
- Fun animations for new game transitions (also when swiping up and down between past games).
Anthony Lockett
24,266 PointsMOVE.h, MOVE.m files not found :( I would love to give this a try
Matthew Mascioni
20,444 PointsStunning, Jo Albright. Nice work!
Jo Albright
5,199 PointsHi Anthony, I apologize for not including that (it is a class I use in all of my projects and forgot to put it in the project folder).
- Added MOVE.h and MOVE.m to project in GitHub
Thanks Matthew! I submitted it to the App Store last night because it turned out much better than I thought it would.
Anthony Lockett
24,266 PointsI am so impressed by this. Amazing job!
agreatdaytocode
24,757 PointsSpectacular job Jo. Well done.
Jo Albright
5,199 PointsThanks Anthony & Aaron!
Enara L. Otaegi
13,107 PointsI can't wait to see this on the App Store. It's really really good Jo!
Amit Bijlani
Treehouse Guest TeacherYou blew this out of the water! Amazing!
Jo Albright
5,199 PointsThank you very much Amit, your words are too kind!
Stephen Whitfield
16,771 PointsThese concepts in your game are above and beyond any online teaching courses dude. Yikes. Great stuff. How in the hell did you implement AI into your app?
Jo Albright
5,199 PointsThanks Stephen. Yea I didn't stop at learning online only, part self-taught and also have taken an iOS class as well. I don't think you are ever too advanced to participate in challenges... and I still have a lot to learn. So, I love joining competitions like this to drive me to learn non-traditional techniques and push my creativeness.
As for the AI... basically a static AI is just a bunch of conditions and randomness to make it feel intelligent. Right now the bot looks for a winning spot, then a blocking spot, then a random spot (this is key as it allows for every game to be different and keeps it interesting). I do have a plan to collect past game information and allow the bot to learn how to play better, making it harder and harder to beat... but that will probably take awhile to implement.
Thomas Nilsen
14,957 PointsAbsolutely stunning design. Also, I really liked you're code. Lot's of stuff to learn from!
Jo Albright
5,199 PointsThank you Thomas! It is always great to hear people appreciating code. Honestly I wrote that very fast, so there is a few spots where I could have made code reusable. I will be making updates to it this week. :)
Anthony Lockett
24,266 PointsDid you go to The Iron yard for the iOS class?
Jo Albright
5,199 PointsI went to the Big Nerd Ranch back in 2012. I teach at The Iron Yard. I send all of my students to Treehouse both for pre-work and for continuing practice as well. I think to become awesome you need a certain amount of group and self-teaching.
Anthony Lockett
24,266 PointsI agree, I want to go to the Iron Yard, but can't leave for the amount of time needed
Anthony Lockett
24,266 PointsDo you recommend any books to read other than Big Nerd Ranch?
Brayden Kness
12,492 PointsWow great UI and I love the robot element
Jo Albright
5,199 PointsThanks Kirk. Glad you like the robot. Was the one element that wanted to make happen in this app.
Jo Albright
5,199 PointsAnthony Lockett - Books I own that I have found helpful.
Although I don't learn best from books, I have enjoyed having them as a good exercise for me to pursue parts of the language I normally would not.
Also, to anyone who really feels it is hard to pursue any language, I would encourage you to find a passion project (an itch to scratch). I have found that most people build amazing things from something they wanted or felt wasn't done right by others. I personally built an app for vector illustration which pushed me to learn Core Graphics very intensely. You also tend to remember code better when you are learning it through an app you are invested in. That is why any app I build for a contest like this has to be something I would submit to the app store... or I will forget what I learned while building it.
Jo Albright
5,199 PointsThank you Enara :)
I really I like how you built yours to play against the computer as well! And your ability to choose which type you want to play as.
Enara L. Otaegi
13,107 PointsThank you Jo! :)
agreatdaytocode
24,757 PointsMy "very simple" Tic Tac Toe App.
You can download it here at GitHub
Tom Bakker
2,132 PointsHere is my entry: Viking XO
I had some great ideas for this app, which I couldn't implement for the app due to some scheduling errors. I expected to have way more free time this week then I actually had, haha.
So here is really the bare minimum version of the app. You can expect an update with a more expanded feature set in the near future. BTW, please don't judge this app on a 3.5-inch screen: it's terribly broken.
Hope there are going to be more of these iOS contest in the future!
agreatdaytocode
24,757 PointsThis is really cool. Well done!
Jo Albright
5,199 PointsBrilliant design!
Holger Liesegang
50,595 PointsHere's my version of the Tic-Tac-Toe App for iOS:
You can download it at GitHub
agreatdaytocode
24,757 Pointsvery nice!
Holger Liesegang
50,595 PointsThank you, Aaron Ackerman , but your's does look way much better :)
agreatdaytocode
24,757 PointsCheers thank you very much!
agreatdaytocode
24,757 PointsI did learn how to display the launch image longer. Here is the Code: "Sleep(number of seconds)"
Appdelegate.M
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
sleep(5);
// Override point for customization after application launch.
return YES;
}
Jo Albright
5,199 PointsNice tip!
agreatdaytocode
24,757 PointsThanks Jo, I actually got the idea after seeing your app. I searched stack Overflow for some example code and found that someone posted this as a comment to a thread. I was shocked that it was so easy lol.
agreatdaytocode
24,757 PointsI like the clean and simple look. Nice job!
Jose Colella
3,526 PointsI like yours better. Good job to you as well.
agreatdaytocode
24,757 PointsCheers Jose!
Matthew Mascioni
20,444 PointsBrilliant job, everyone! You're making this really hard on the team ;) So many collective great ideas going on in here. This is what it's all about!
agreatdaytocode
24,757 PointsMatthew thank you for the very kind words but my money is on Jo Albright.
Holger Liesegang
50,595 PointsYup, I like to second Aaron's opinion concerning Jo's fantastic work :)
Jo Albright
5,199 PointsThanks Aaron, but I agree with Matthew. There are multiple ideas here that I am now wanting to implement in my app, as I did not thing of them before.
Aaron :
- I love the movement in and out of your game with a home screen
- The exit button to leave a game is also very kind to a user
- Plus your personal logo is awesome
Enara :
- Great idea of allowing the user to choose a player type
- Good implementation of playing against the computer
- Fun play on the logo and the "T"
Tom :
- Dude that viking design is amazing... colored shields and the banners denoting whose turn it is rocks
And everyone else who has submitted have figured out how to get this game to work in different ways. It is really cool to see how different brains come to different conclusions. The two main reasons I love Treehouse 1) their content is very creative and constantly keeps me interested 2) the community they are building is very diverse and brilliant.
Good luck to everyone!
Jose Colella
3,526 PointsMe too. Jo Albright's app is amazing. Innovation,and simplicity in one app..
Jo Albright
5,199 PointsDude. Too kind. I got really excited when the iOS 7 design was released, because that style is my jam!
Thomas Nilsen
14,957 PointsJo Albright I particularly liked the way you used delegates. I always use them just to pass data from viewController B to A. But you used it for a lot more as well.
Hans Yelek
9,178 PointsAh! I hate turning in an incomplete project, but I've run out of time. Here's an introduction to my app: Entry
Jo Albright
5,199 PointsDude... cool animations and smart way of showing whose turn it is. Very cool ideas coming out of your brain. I hope you finish this out in the future.
agreatdaytocode
24,757 PointsThe animation is sweet! nice job Thomas.
Chad Donohue
5,657 PointsI agree with Jo Albright on this one, very sweet prompt for the current turn. Nice work!
Hans Yelek
9,178 PointsThanks, guys - I appreciate your comments! I do plan on finishing this one up; it will be my first complete app.
All of your apps are looking well too - excellent work around this forum.
agreatdaytocode
24,757 PointsNice Job Hans! very cool animations!
agreatdaytocode
24,757 PointsI've noticed that some of the seasoned developers here don't use storyboards. Can I ask why?
Jo Albright
5,199 PointsI use storyboards in some projects. 2 personal projects that I am currently building rely on storyboards. But, I think they can be overkill for some projects and other projects they just feel like they are in the way.
For this project... I could have done a storyboard, but I work faster with code. I have set it up so that I can add a storyboard later when I choose to add features like color themes, p2p games, etc.
For other projects I do a lot of CoreGraphics drawing which I currently have not figured out a way to visualize in storyboards (if there even is a way).
In the end, I believe you should know how to build an app only with code (so you know what is going on behind the scenes of storyboard). Once you understand how it works, then you should choose whether an app really needs it or if you do it as a practice that makes you build apps faster.
agreatdaytocode
24,757 PointsThat's some good advice. I'll need to work on creating apps with the storyboards. I've never done it that way.
Matthew Mascioni
20,444 PointsI started learning iOS development using storyboards-- they are quite useful to get to learn visually how the view hierarchy works. It also spares you from writing a lot of redundant code during development with managing said view hierarchy with smaller apps. However, I find that I'm a lot more efficient with code and having everything in code in front of me helps me to diagnose problems faster. A lot of it is preference and use case.
agreatdaytocode
24,757 PointsThanks for sharing Matthew!
Thomas Nilsen
14,957 PointsI truly comes down to perference. Read this :) http://codewithchris.com/xcode-using-storyboards-and-xibs-versus-creating-views-programmatically/
Also. The new IOS course that gets released tomorrow (at least in my timezone), Amit has said that everything will be done programmatically ;)
Btw - You said nice job Thomas - I think you meant Hans Yelek? ;)
https://www.dropbox.com/s/bqahgfs1rdf5w9x/Tic%20Tac%20Toe.zip
Here is my code if you want to have a look :) Really liked your design btw!
agreatdaytocode
24,757 PointsThe animations in your app are just as cool!
qvwzucovkm
8,080 PointsA bit late, but still on time! Here is my link.
Matthew Mascioni
20,444 PointsI like! :D
Jo Albright
5,199 PointsVery fun design! And I like the ? for stalemate.
Jo Albright
5,199 PointsThat "?" was supposed to be the infinity symbol. Looked right in the input field. :)
qvwzucovkm
8,080 PointsI left the 2P and Options screen unimplemented, but will follow up with that tomorrow. Great work everyone and hoping for more iOS contests from TeamTreeHouse here as well.
agreatdaytocode
24,757 PointsWOW that is good! Graphics are awesome!
Jon Kroeker
24,649 PointsGreetings everyone,
First iOS project of my own after completing the three in the iOS track, and first entry into a Treehouse forum contest. I went with the paper and pencil design, and the basic two player game functionality with a reset. I'm still learning what I can about coding applications having only started in January, but I got to start somewhere. You'll find it on GitHub @ GitHub Link
Jo Albright
5,199 PointsGreat job for a first app on your own. Keep it up!
agreatdaytocode
24,757 PointsWell done. You should add Ninja icons for O and Pirate icons for X. And Then you can call the app Pirates vs Ninjas lol.
Chad Donohue
5,657 PointsHere is my submission. I am a Java and front end web developer taking my first steps into iOS development.
I hope to learn quite a bit and am excited with the submissions that I have already seen.
Best of luck to you all.
agreatdaytocode
24,757 PointsGreat job Chad!
Thomas Nilsen
14,957 PointsAmit Bijlani This was a great contest. Congrats to the winner, Jo Albright. Also I was just wondering when the new IOS course will be released. It says today, so I'm waiting eagerly! :)
Amit Bijlani
Treehouse Guest TeacherWe will release it by 5pm EST today. Just conducting some final checks before release. Meanwhile, checkout the short CocoaPods course we released over the weekend, which helps you install third party libraries.
Stephen Whitfield
16,771 PointsWhat new iOS course?
Thomas Nilsen
14,957 PointsAmit Bijlani Already done that. But thanks. Nice to have a time to look to ; )
Stephen Whitfield
16,771 PointsOhhhhh... YAY!
agreatdaytocode
24,757 PointsAlready started it lol
Brayden Kness
12,492 PointsJo Albright what did you use to make the robot work?
Jo Albright
5,199 PointsWhat the robot does :
I have three formulas to choose a spot :
Check for a winning spot : which looks through every set of three to find 2 spots owned by the robot and the third spot is free.
Check for a blocking spot : if no winning spot, then do the same loop but looking for the users 2 owned and 1 free set.
Random spot : if neither of the above are found, take all of the available spots and choose a random spot to select.
The random spot allows for gameplay to be different each time. And I change who starts each game to give advantage to both sides.
I also added a time delay and spinner at the top to make it look like the robot is thinking when choosing a spot... giving it a humanistic quality (and the thought of fallibility). Normally the choice would be instantaneous and feel like you are playing against an unbeatable machine.
Enara L. Otaegi
13,107 PointsJo Albright, I've been watching the WWDC 2013 Session Videos and they were talking about this blurry effect they do in the control center and so on. And I thought about your app, (I liked that blurry effect soooo much). So, I don't know if you were aware of this but maybe you could use it to save some code drawViewHierarchyInRect:afterScreenUpdates:. "Use this method when you want to apply a graphical effect, such as a blur, to a view snapshot."
Stephen Whitfield
16,771 Points<3! I was curious about this too. Thanks Enara.
Jo Albright
5,199 PointsSo there are implications to using special methods that do things under the hood for you. Yes it simplifies parts of your code, but you lose speed a lot of times. In this case, that blur method in the Tic Tac Toe app (which is partly found code that I have modified and simplified it even more), so far is the fastest blur render I have tested. I use it in my app Liltool, which is a vector drawing app. I do a live render blur for the top and bottom bars and it needs to render as fast as possible as you drag things around.
So short answer, yes there are simpler ways of doing them... but I am one of the last people to use simple methods, as I enjoy as close to total control over my environment as possible. For my drawing app, everything is done with CGContext and methods like CGContextAddCurveToPoint, CGContextSetBlendMode, etc.
Enara L. Otaegi
13,107 PointsI guess I was assuming that Apple provides us better methods for all cases, but it depends on our needs really. Thank you for sharing your experience, this is very useful.
Thomas Nilsen
14,957 PointsJo Albright I was just wondering. In your code, when you implement the protocols and delegates. Why does yours say:
@property (nonatomic, assign) id <TTTGameCellDelegate> delegate;
and not
@property (nonatomic, weak) id <TTTGameCellDelegate> delegate;
agreatdaytocode
24,757 PointsHi Thomas, great question! After searching via google and a few other sites like stack overflow here is what I found.
I'm sure Jo will have a better answer for you but I hope that helps.
Strong is the same as retain in a property declaration, so for ARC projects use strong instead of retain.
Use assign for C primitive properties and weak for weak references to Objective-C objects.
//Link below to stack overflow answer:
//http://stackoverflow.com/questions/8927727/objective-c-arc-strong-vs-retain-and-weak-vs-assign
Jo Albright
5,199 PointsThanks Aaron Ackerman for answering very quickly. And yes, that is basically the answer (under normal conditions).
Note : Apple documentation does write weak when describing how to create a delegate. But it does not explain why weak instead of assign, only that you should not use strong.
Like every other convention known to man, this is debated because of different view points. Most people just debate based on partial information (I am not immune to this).
Some people build delegates that will deallocate before the class that is accessing it. Since this happens they want it to be weak so that when the delegate is sent a message, the delegate will be nil instead of a dangling pointer. This seems to have happened with people running multi-threaded actions that make timing an unsure thing. I honestly don't know what use case would warrant that situation. And I would first question is what they are doing correct.
In this app, I have no items that will call a delegate after it was deallocated. So I write assign for delegates, mostly to keep myself inline when building apps. No, I am not against writing weak, this is just a convention I have learned from someone smarter than me.
Basically, you should never do something because one person says that is the way you should do it. You need to understand the situation and the consequences from your actions.
Hopefully this is helpful information.
Thomas Nilsen
14,957 PointsJo Albright and Aaron Ackerman Thank you both for good answers!
agreatdaytocode
24,757 Pointsagreatdaytocode
24,757 PointsGood Luck to everyone!