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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:43:12+00:00 2026-05-13T19:43:12+00:00

I am working on an iPhone app that will construct, at run-time, an NSMutableDictionary

  • 0

I am working on an iPhone app that will construct, at run-time, an NSMutableDictionary for which the values (of the key-value pairs) will be NSMutableArrays. Being somewhat new to the Objective-C, I am concerned that the following will cause a memory leak:

- (void) addNewSupplierPhoto:(UIImage*)image toSupplierID:(NSInteger*) supplierID{
NSMutableArray* supplierPhotoArray = [supplierPhotos objectForKey:supplierID];
if(supplierPhotoArray == nil)
{
    supplierPhotoArray = [[NSMutableArray alloc] init];
    [supplierPhotos setObject:supplierPhotoArray forKey:supplierID];
    [supplierPhotoArray release];
}
}

supplierPhotos is an NSMutableDictionary, which is a member variable of the containing class.

As you can see, when I am accepting a new UIImage* to put into the structure, I first check to see if the object at the key-value pair corresponding to the second argument (supplierID) is nil. If it is nil, I alloc a new NSMutableArray and set it as the object for that key, then release it. Assuming I dealloc the NSMutableDictionary in the dealloc of the class containing this method, will the references be released? Before dealloc-ing the NSMutableDictionary, do I need to run through it and dealloc the individual NSMutableArrays contained within?

Thanks,

Ben B.

  • 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-13T19:43:12+00:00Added an answer on May 13, 2026 at 7:43 pm

    when you add objects into an container like dictionary or array, retain will be invoked automatically, and when you release the container as your question it’s dictionary, it will call ‘release’ of every object to dealloc the object’s memory.

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

Sidebar

Related Questions

I'm working on an iPhone app that will upload images to a web server.
I'm working on an iphone/ipod app that will need to communicate with a computer
I'm working on an iPhone app that, at a certain point, will try to
I am currently working on an iPhone app that will have a user log
I'm working on an iPhone app that gets a number of objects from a
I'm working on an iPhone App that relies heavily on OpenGL. Right now it
I'm working on an iPhone app that uses Core Data. The app makes a
I am making an iPhone app that is designed for things that will be
Hey, I'm working on an iPhone app but I've heard from some people that
I'm working on an iPhone app using objective C. I've got class A, which

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.