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

  • Home
  • SEARCH
  • 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 6941427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:53:04+00:00 2026-05-27T12:53:04+00:00

I have @interface PlayerDeck : Deck @interface MasterDeck : Deck Both PlayerDeck and MasterDeck

  • 0

I have

@interface PlayerDeck : Deck
@interface MasterDeck : Deck

Both PlayerDeck and MasterDeck have

@property (nonatomic, strong) NSMutableArray *cards;   // All cards in this Deck

Inside Deck’ I’d like to

-(NSString*) descriptionOfDeck: (Deck *) deck

Inside both PlayerDeck and MasterDeck i’d like to

-(NSString*) description{
    [super descriptionOfDeck:self];
}

Inside Deck i will iterate over cards inside each individual Decks:

-(NSString*) descriptionOfDeck: (Deck *) deck {

    NSString *deckDescription = [[NSString alloc] init];

    for (Card *c in [deck cards]) {
        deckDescription = [deckDescription 
                 stringByAppendingString:[c description]];
    }

    return deckDescription;
}

The problem: [deck cards] does not resolve.

Please help me understand.

  • 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-27T12:53:04+00:00Added an answer on May 27, 2026 at 12:53 pm

    If I understand correctly, you’re saying the cards property is only defined on the MasterDeck and PlayerDeck classes, and not on Deck.

    If that’s correct, consider the type of deck when you attempt to send it the cards message: it is of type Deck, which doesn’t define cards. You need to either cast it to a type which does define cards, or define cards in the base class directly. The latter seems more sensible, both for resolving this issue, and because it seems appropriate that all Decks have cards!

    Update: An example of casting in your case would be:

    for (Card *c in [((MasterDeck *) deck) cards])
    

    But you can see the problem with that, can’t you? It requires the base class to somehow know about its child classes, which sort of defeats the purpose of inheritance.

    As I – and @rgeorge, in the comments – have suggested, declaring the cards property in the base class is the better move.

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

Sidebar

Related Questions

I have interface IResourcePolicy containing the property Version . I have to implement this
Say I have: @interface Test : NSObject { NSString *string1; } @property (nonatomic,retain) NSString
I have the following situation, i can't resolve: @interface Deck : NSObject @interface MasterDeck
I have: @interface A @property (nonatomic, retain) B *toB; @end @interface B @property (nonatomic,
I have custom control and I have interface this control exposes to it's users.
I have custom control and I have interface this control exposes to it's users.
I've got WebView, JS code inside it. Also I have interface to allow Java
I have: @interface SuperClass : UIViewController <UITableViewDelegate,UITableViewDataSource> And then @interface SubClass : SuperClass This
I have interface defs like below. public interface IProvider { } public interface IProviderList
Let's say I have interface IMatrix { double this[int r, int c] { get;

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.