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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:39:54+00:00 2026-05-14T15:39:54+00:00

I hope to store MYFileObj to NSMutableArray (fileArray) and display data on an UITavleView(tableview).

  • 0

I hope to store MYFileObj to NSMutableArray (fileArray) and display data on an UITavleView(tableview).

//----------------------------------MYFileObj
#import <UIKit/UIKit.h>


@interface MYFileObj :  NSObject  {

    NSString *fileName;

}

-(void) setFileName:(NSString *)s ;
-(NSString *) fileName ;


@end

the array I want to store data

NSMutableArray *fileArray;

I created new object and add to fileArray

MYFileObj *newobj=[[MYFileObj alloc] init ];
NSString *ss=[[NSString alloc] initWithFormat:@"%@",path]  ;
[newobj setFileName:ss];
[ss release];
[fileArray addObject:newobj];
[newobj release];

[atableview reloadData];

After the first time relaodData and do something, I want to reload fileArray and redraw atableview.

//code to remove all object in atableview
if([fileArray count]>0)
{  
   [fileArray removeAllObjects];
   [atableview reloadData];
}  

I notice that there are memory leak.
I hope to know the method “removeAllObjects” removes only MYFileObj themselves or also removes MYFileObj’s member property “fileName”?

Thanks

interdev

  • 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-14T15:39:55+00:00Added an answer on May 14, 2026 at 3:39 pm

    A good practice is to use retain/release in the setter. This way you avoid unnecessary object creation/copy:

    - (void)setFileName:(NSString *)s {
        [s retain]; // <- Retain new value
        [fileName release]; // <- Release old value
        fileName = s;
    }
    
    - (NSString *)fileName {
        return fileName;
    }
    
    - (void)dealloc {
        [fileName release]; // <- Release the instance
        [super dealloc];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I hope this makes sense, I am trying to store a SQL Server 2008
I hope it exists. I would like to store the time when the application
Hope someone can help me with this.. I have a magento store up&running, via
I want to store an actually version of each filename into a textfile. And
I am using Excel to store data kind of as a relational database for
I am writing a C++/MFC application that will use Microsoft Access to store data.
I'd like to be able to use an alternate data stream to store some
I need to store data temporarily at the client-side to allow users to add,
I'm building an application that I hope to submit to the Mac App Store.
I couldn't find any resource for Amazon app store submission help, so I hope

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.