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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:08:32+00:00 2026-05-28T18:08:32+00:00

In a Utilities class, I have the following method: + (Division *) getNationalDivision {

  • 0

In a Utilities class, I have the following method:

+ (Division *) getNationalDivision
{
    Division *defaultDivision = [[[Division alloc] init] autorelease];
    defaultDivision.Id = 0;
    defaultDivision.name = @"National";

    return defaultDivision;
}

I have a division allocted in my app delegate to store the division throughout the app, so in one of my view controllers I have:

appDel.currentDivision = [[Utilities getNationalDivision] retain];

In the app delegate .h I have:

@property (nonatomic, retain) Division *currentDivision;

In the app delegate .m I have:

currentDivision = [[Division alloc] init];

When I analyze, I get potential leak of an object that points to the above line. Any ideas? If I dont retain the national division, it doesnt work. Also, just to note, everything works fine. I just want to make sure I am not leaking something.

  • 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-28T18:08:33+00:00Added an answer on May 28, 2026 at 6:08 pm

    Check how you declare the property currentDivision in your app delegate. If it is assign (which I suppose, since you are retaining it before assigning through the property) then the original value you assigned to it:

     currentDivision = [[Division alloc] init];
    

    will not get released when you execute:

     appDel.currentDivision = [[Utilities getNationalDivision] retain];
    

    hence, the object you created in the app delegate will leak. Do a release manually and check whether the analyzer keeps complaining:

    [app.currentDivision release];
    

    This only makes sense in case your property is declared as assign.

    In case it is declared as retain, then the fault is on line:

     appDel.currentDivision = [[Utilities getNationalDivision] retain];
    

    where you should not do the retain manually.

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

Sidebar

Related Questions

I have a static method in a Utilities class: + (Division *) getDefaultDivision {
Assume I have a class library project name Utilities.dll as follows: public static class
We currently have a utilities class that handles a lot of string formatting, date
I have a model, Show and a module Utilities class Show < ActiveRecord::Base include
I have a class proposing translations utilities. The translations themselves should be reloaded every
I have a class that utilizes a directory swap method for the Environment.CurrentDirectory. The
I am making a utilities class that among other frequently used code have some
I think I'm missing something pretty basic here. I have a Utilities class that
I have the following method of copying files: public static void nioCopy(File source, File
In a code-behind I have a method that consists of the following: Response.Clear(); Response.ClearHeaders();

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.