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 6780431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:30:18+00:00 2026-05-26T16:30:18+00:00

I have another odd problem with Objective C inheritance. I have a protocol called

  • 0

I have another odd problem with Objective C inheritance. I have a protocol called IGameObject, a class GameObject that inherits from NSObject and IGameObject and finally a Player that inherits from GameObject..

The problem is that when I assign a Player* to a IGameObject*, this produces an error, but it works ok when I assign a Player* to a GameObject*. I haven’t seen that this is not possible in all I have read. Here the code:

-(IGameObject*) clone
{
    Player* p=(Player*) 0xFFfFFFFF;
    //Throws an error saying that Cannont initialise a variable of type IGameObject with an value of           Player*
    IGameObject* go=p;

    //This works perfectly
    GameObject* go2=p;

    return [[Player alloc] initWithGameObject:self];
 }

Could anybody guess what is happening?

Thanks in advance.

  • 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-26T16:30:19+00:00Added an answer on May 26, 2026 at 4:30 pm

    When returning (or declaring) a type that is only known by its interface, don’t treat it as an object pointer. Instead, use:

    -(id<IGameObject>) clone {
    

    And:

    id<IGameObject> go=p;
    

    This should clear up that warning.

    Sidenote: Why in the world are you assigning p to a memory address?!

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

Sidebar

Related Questions

I have an odd problem. I have a page called search.aspx. When the search
I have an extremely odd problem in my JUnit tests that I just can't
I have a really confusing problem. I have a PHP script that polls another
i have some SQL code that is inserting values from another (non sql-based) system.
I have an odd problem. I'm trying to echo the response from a file
I have another programmer who I'm trying to explain why it is that a
I have a DataTable populated with values from a database. I have another datatable
I have a form (Form1) that has a NotifyIcon on it. I have another
I have a base class where I derive several classes. I have another class
I have a table (user) that contains user information. I have another table (userview)

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.