Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7089997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:59:26+00:00 2026-05-28T07:59:26+00:00

I am working on a card game iPhone app and have a question about

  • 0

I am working on a card game iPhone app and have a question about both method of communication and responsibility of various components.

In my application, the ViewController in it’s viewWillAppear, creates instance of the View class and initializes it. ViewController creates the view and points strongly to it.

[self setGameView:[[GameView alloc] initWithFrame:CGRectMake(0, 0, 480, 300)]];

Inside the GameView, i lay out cards on the view and make sure they can be moved according to some rules.

A few questions:

Given that some cards can “beat” other cards, should View or View Controller be in charge of this decision? For instance, at this point, any card can be placed on top of any card, as long as they are in the same region, however, sometimes, cards should snap back and other times program should recognize that card has beaten another card.

In this event, should View notify the its Controller that “card A is placed on top of card B – go figure out if A actually beats B”. If Controller decides that A can’t beat B, Controller should instruct it’s view to snap A back to stack, where as if A indeed has beaten B, it should remain where it is and some other things should happen?

How should communication happen here?

I am thinking that in it’s – viewWillAppear method, ViewController should subscribe to NSNotificationCenter asking to be made aware the next time card is placed on top of another card. Since View is owned by ViewController it has access to all of it’s public interface methods and can figure out from there what card is in what place and why.

Is NSNotification a good way to handle this, or is there a better way to do it?

As you can see from my question, i am a bit confused here. Please help clarify this for me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:59:27+00:00Added an answer on May 28, 2026 at 7:59 am

    To start with, I’d say that neither the View or the ViewController are in charge of how cards behave. That should be the realm of the Model. Take a read of Model View Controller core competencies. Also take a look at Communicating with Objects

    The View should feed user actions to the Model, and the the Model should tell the View how to react.

    As to actual implementation of passing information around, NSNotifcations are a valid choice. However there are other choices such as creating custom protocols Protocols are another way of doing things. They require defining a delegate object that fulfills the messages supported by the protocol.

    If you were going to use NSNotifications, I would structure it like:

    On initialization the Model subscribes to “User Change” events

    On the View’s loadView(), the View subscribes to “Card change” events

    On the View’s viewWillAppear() method, the View sends and “update
    request” (as an overall “User change”) to the Model, which replies
    with a sequence of “Card changes” that layout the card on the screen,
    which the View receives and then dutifully displays the cards

    During game play the user interface sends “User change” events, to
    which the Model responds with more “Card change” events

    This structure separates the View and Model and hence makes things cleaner to code and to debug. The ViewController is then left to do View Controller things like displaying other View Controllers that might show hi score histories etc.

    Doing the above with Protocols would require creating “User Change” and “Card Change” protocols, with the Model implementing the “User Change” protocol and the View implementing the “Card Change” protocol. The Model would then have the View as its delegate and the View would have the Model as its delegate.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Rails app representing a card game. There are several different types
I am working on a card game and among other things have a UIView
I new to app development and I have been working on a Flash card
I'm working on an iPhone app in which I'm trying to create a card
I'm working on a card game in C# for a project on my Intro
I am working on a little card-swapping world-travel game that I sort of envision
My OpenGL application which was working fine on ATI card stopped working when I
I have an application that uses a file on the SD card, the application
Suppose I am working on a card game, and I am using the numbers
I'm creating a DSL for an extensible card game engine I'm working on, with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.