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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:54:18+00:00 2026-06-04T18:54:18+00:00

Say I have a BasicEngine class: @interface BasicEngine : GfxEngine{ NSMutableDictionary *keyNodes; AbstractVirtualJoystick *input0;

  • 0

Say I have a BasicEngine class:

@interface BasicEngine : GfxEngine{

    NSMutableDictionary *keyNodes;
    AbstractVirtualJoystick *input0;
}

The related implementation goes as follows:

@implementation BasicEngine
- (id)init {

    if ( (self = [super init]) ) {

        keyNodes = [NSMutableDictionary dictionary];
    }
    return self;
}

My understanding is that calling [ dictionary] returns an autoreleased object. However, this dictionary should be kept in memory as long as the BasicEngine instance is available.

I realise I’m missing something as keyNodes quickly becomes a nil object.
Using [keyNodes retain] in the init method just helps, but I can’t understand why a class member needs to be retained.

Please help me understand this 🙂
Thanks.

  • 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-06-04T18:54:19+00:00Added an answer on June 4, 2026 at 6:54 pm

    retain implies ownership of the retainer on the retainee. Since keyNodes is a class member, your engine “owns” it, and thus should retain on it.

    Under the hood retain is incrementing the reference count on keyNodes, which signals to the system that one more object is interested in keeping whatever keyNodes points to around in memory. Similarly, you’re expected to call release on keyNodes in your dealloc method, which will decrement the retain count as your engine no longer “owns” keyNodes.

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

Sidebar

Related Questions

Say I have the controller as follows: public class Controller { ISomeService _service; public
Lets say have this immutable record type: public class Record { public Record(int x,
Say I have 2 div s with the same CSS class that are stacked
Say I have a class pet and it is composed of two variables: Class
Say I have the following template function: template <class T> void apply(const vector<complex<T> >&
Say I have an Intent like this: Intent intent = new Intent(context, MyActivity.class); I
let say have element like this <div class=watch-me style=display: none;>Watch Me Please</div> as we
Say I have a class called Money which has parameters Dollars and Cents I
Say I have a class with synchronized methods. It's actually a class that uses
Say I have a class named Frog, it looks like: public class Frog {

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.