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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:59:50+00:00 2026-06-18T04:59:50+00:00

my.h file @interface myObject : NSObject { NSMutableDictionary *myDictn ; } i have a

  • 0

my.h file

@interface myObject : NSObject {
    NSMutableDictionary *myDictn ;
}

i have a property

@property (nonatomic,retain) NSMutableDictionary *myDictn ;

then in .m File

i have a allocated it from id

- (id)init {
    if (self=[super init]) {
        myDictn= [NSMutableDictionary  alloc]init];
    }
}

my Question is i have mentioned Retain in Property and i have allocated memory also (is Retain Count goes to 2 in (id)init )
so how to manage memory in this case ?
i am new to this so dnt have much idea regarding memory management .

one more thing if i have a method x in my code and i also allocated memory to myDictn then in that case also how can i use release .??
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-06-18T04:59:51+00:00Added an answer on June 18, 2026 at 4:59 am

    The proper way to initialize a retained property is:

    NSMutableDictionary *newDict = [[NSMutableDictionary alloc] init];
    self.myDictn = newDict;
    [newDict release];
    

    or alternatively:

    self.myDict = [NSMutableDictionary dictionary];
    

    The first method makes sure not to increase the already retained property’s retain count by performing alloc,init (an action that increments retain count) on a temporary object.

    The second method uses a convenience method for obtaining an autoreleased instance of the dictionary.

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

Sidebar

Related Questions

I have the following: Class 1: .h file: @interface class1 : UIViewController @property (assign,nonatomic)
I have a custom button class: CustomButton.h file: @interface CustomButton : UIButton @property (nonatomic,
I will explain my question from an example. In .H file// @interface Employee:NSObject{ @private
I have tried this: In .h file : @interface TouchLabelViewController : UIViewController<UITextFieldDelegate> @property (strong,
I have the following code in my .h file: @interface Utils : NSObject {
I have this method in my Car.h class file: @interface Car : NSObject {
I have problem with TableView its empty. In (.h) file: @interface TableViewController : UITableViewController{
I have added eth0:1 with one more ip to the interface file of my
I have a BOOL value inside my @interface definition in my .h file. Here
Here's the header file: @interface calc : NSObject { IBOutlet NSTextField *tf1; IBOutlet NSTextField

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.