cs193p – Assignment #3 Task #1

Please note, this blog entry is from a previous course. You might want to check out the current one.

Add a new MVC to your Matchismo solution from last week which plays a simple version of the card matching game Set. A good solution to this assignment will use object-oriented programming techniques to share a lot of code with your Playing Card-based matching game.

For convenience (and to confuse you), I followed the tasks of this assignment slightly out of order. But now, I should be back to the “correct” order.

As model, we need a set card and its deck. Create SetCard as subclass of Card and SetCardDeck as subclass of Deck.

As controller create SetCardGameViewController as subclass from CardGameViewController.

Finally as view, remove the second view controller (which came with the tab-bar controller). Duplicate the PlayingCardViewController link it to the tab-bar controller and change its class to SetCardGameViewController:

cs193p – assignment #3 task #1 – new MVC
cs193p – assignment #3 task #1 – new MVC

The playing-card tab should work like before. Selecting the set tab will work to, but as as soon as you click anything else, the app will crash … because the model and the view controller are still empty and derive their functionality from the generic parent function … and the card-matching-game class does not check for such a case … and crashes …

The complete code is available on github.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

3 thoughts on “cs193p – Assignment #3 Task #1”

  1. So, I’m not sure what’s going on here, but I get a ‘View hierarchy unprepared for constraint’ and each of the UIButtons give me a ‘NO SUPERVIEW’ error when I add in the SetCard controller. This has been bugging me for awhile. Everything else works and makes perfect sense, but I can’t seem to make this go away.

    If I put in breaks I find that the error happens internally, after the -(void)viewDidLoad is called (and after the ‘Set’ tab is clicked, of course). There’s no problem with the code itself.

    I’ve even gone so far as to ‘copy paste’ your MVC in and it still has the issue. No dice. Or, in this case, cards.

      1. It turns out I was being foolish. While working on some other ideas I had added a sublayer into the -(void)viewWillAppear, and that sublayer was somehow masking one of the buttons and causing all kinds of crazy problems which didn’t appear normally via debugging. By more carefully instantiating that, it solved the issue. Whoops.

Leave a Reply

Your email address will not be published.