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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:40:13+00:00 2026-06-09T13:40:13+00:00

I am doing my project in xcode 4.2 (Older Version). For my application, I

  • 0

I am doing my project in xcode 4.2 (Older Version). For my application, I just set the variables, arrays in dto class for using in entire app lifecycle. so I set with a property like this.

AppDTO(sub class of NSObject)

AppDTO.h

@property(nonatomic,retain)anotherAppDTO *aAppDTO;
@property(nonatomic,retain)NSMutableArray *array1;
@property(nonatomic,retain)NSMutableArray *array2;
@property(nonatomic,retain)NSString *string1,*string2,*string3;

AppDTO.m

- (id)init
{
    self = [super init];
    if (self) {

    self.aAppDTO = [[anotherAppDTO alloc]init];
    self.array1 = [[NSMutableArray alloc]init];
    self.array2 = [[NSMutableArray alloc]init];

    self.string1 = @"Hello";
    self.string2= @"Hai";

    }
}


-(void)dealloc
{
    if(array1 != nil)
    {
        [array1 release];
        array1 = nil;
    }

    if(array2 != nil)
    {
        [array2 release];
        array2 = nil;
    }

    [aAppDTO release];
    aAppDTO = nil;

    [super dealloc];
}

when I analyze my app in Xcode 4.3.2, I get memory warning in self.array1 and self.array2 (Potential leak on object allocated on line….), but when I change self.array1 to array1, warning goes away.

What is the reason for using self. do I need to use self if I set @property(nonatomic,retain) to variables(like array1,array2,string1,string2).

Also in dealloc method, I heard we don’t want to use [self.array1 release], instead we can use [array1 release]. Is it Correct?

Do I need to release my string in dealloc method.

Also I am releasing aAppDTO in dealloc method. if I allocate some objects in anotherAppDTO class, will it release automatically when I call [aAppDTO release] method.

Can anyone clarify me.

Many Thanks,
Anish

  • 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-09T13:40:15+00:00Added an answer on June 9, 2026 at 1:40 pm

    You get the warning because when you write :

    self.array1 = [[NSMutableArray alloc]init];
    

    is the same as :

    [self setArray1: [[NSMutableArray alloc]init]];
    

    As you can notice you are not allocating the underlying array1 private variable, but you are calling the setter of the property that since it is declared as retain it retains the object once assigned, this means that when you eventually will assign another object the second time with the setter the first object will remain with a retain count of one until the application will be closed (since you don’t have any reference to that object anymore …) .

    Take a look at this great article to understand better Manual Reference Counting in Objective-C .

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

Sidebar

Related Questions

I just created a new Xcode project. In the AppControl class Header file I
I am doing iOS project in Xcode . It was working properly but now
I have an old project developed with Xcode 4, i remember doing xarchive on
I'm doing project on object detection using javacv in that I went through couple
I just installed the new XCode with iPhone SDK 4.0. On my project, I
I have an XCode project, with the XIB interface files built using Interface Builder.
Using the Python templates for Xcode, I have a simple project running on one
I created a static cocos project in xcode, the entire project consisted of a
I am working on a C++ project using Xcode on MacOS X, and am
I have just updated to Xcode 3.2 Beta 3. Since doing this - the

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.