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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:52:30+00:00 2026-05-23T21:52:30+00:00

I have a property in my header file as @property (nonatomic,retain) NSMutableDictionary* e; and

  • 0

I have a property in my header file as

@property (nonatomic,retain) NSMutableDictionary* e;

and in my viewDidLoad: method allocated it like

self.e = [[NSMutableDictionary alloc] initWithContentsOfURL:myURL];.

The XCode static analyser is triggered, and says 'Potential leak of an object...' obviously. But when I release the object ([self.e release] in dealloc) the error persists, but now it also is saying that there is an “incorrect decrement of the reference count”, and that this object is not owned by the caller (my viewController).

The ‘incorrect decrement…’ error goes away when I replace [self.e release] with simply [e release]. But the former error about potential leak is still there. What is the problem?

  • 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-23T21:52:31+00:00Added an answer on May 23, 2026 at 9:52 pm

    This statement:

    self.e = [[NSMutableDictionary alloc] initWithContentsOfURL:myURL];
    

    is over-retaining the object. Both alloc-init and the property retain the object.

    In terms of ownership, you own the object returned by alloc-init and by sending it a retain message in the property accessor you claim ownership of it again, which results in the object being over-retained.

    You can use a convenience constructor, which returns an object yo do not own, and let the property accessor claim ownership of it:

    self.e = [NSMutableDictionary dictionaryWithContentsOfURL:myURL];
    

    Or make use of autorelease:

    self.e = [[[NSMutableDictionary alloc] initWithContentsOfURL:myURL] autorelease];
    

    Or use a temporary variable:

    NSMutableDictionary *tempDict = [[NSMutableDictionary alloc] initWithContentsOfURL:myURL];
    self.e = tempDict;
    [tempDict release];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UILabel in my class header file defined as : `@property (nonatomic,
I have a custom UITableViewController with 2 properties: @property (strong, nonatomic) IBOutlet VenueHeaderViewController *header;
I have declared a property in the header file, for example @interface myClass {
I have a property of type uint on my entity. Something like: public class
I know that if I retain an IBOutlet by using property then I have
EDIT: I SOLVED IT I solved it. I changed: @property(nonatomic,retain) UIActivityIndicatorView *activityIndicator; to @property(nonatomic,retain)
I have a singleton here is the header file: #import <Foundation/Foundation.h> @interface Shared :
If I have a delegate which resides within its own header file myDelegate.h. Then
I have a ViewController class with the following structure: Header file: @protocol GCStageViewControllerDelegate; @interface
Short Version: I define a property with (nonatomic, retain) and assumed that the property

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.