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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:09:30+00:00 2026-06-08T18:09:30+00:00

this is my code: array = [[NSMutableArray alloc] init]; NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory,

  • 0

this is my code:

array = [[NSMutableArray alloc] init];



NSArray *paths = NSSearchPathForDirectoriesInDomains
(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];


//make a file name to write the data to using the
//documents directory:
NSString *fullFileName = [NSString stringWithFormat:@"%@/file", documentsDirectory];

array = [NSKeyedUnarchiver unarchiveObjectWithFile:fullFileName];

What’s Wrong in my code?

This is the error

[__NSArrayM count]: message sent to deallocated instance 0xd5864e0
  • 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-08T18:09:31+00:00Added an answer on June 8, 2026 at 6:09 pm

    The statement

    array = [NSKeyedUnarchiver unarchiveObjectWithFile:fullFileName];
    

    will give you back an autorelease object that will be deallocated at the first appropriate moment. So, when you later access its count method, the object is not there anymore. This is what is causing the crash.

    A way to fix this is properly managing your array so that it stays there as long as you need it. If you are using ARC, this could mean managing the object through a strong property; if you are not using ARC, this involves using retain. You do not specify how array is declared so I cannot be more precise.

    Since you say that the property is declared as:

    @property (nonatomic,retain) NSMutableArray *array
    

    simply doing:

    self.array = [NSKeyedUnarchiver unarchiveObjectWithFile:fullFileName];
    

    should fix the problem.

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

Sidebar

Related Questions

NSMutableArray*array = [[NSMutableArray alloc]init]; NSArray*Somearray = [NSArray arrayWithObjects:1st Object,2ndObject,3rd Object,4th object,5th Object,nil]; In the
In this code: - (void)connectionDidFinishLoading:(NSURLConnection *)connection { //---initialize the array--- listOfJMovies = [[NSMutableArray alloc]
My codes: NSArray *array = //objects here NSMutableArray *mutarray = [[NSMutableArray alloc] init]; for
I have this little code NSMutableArray *myArray = [[NSMutableArray alloc] init]; NSNumber *myNumber =
I created an NSMutableArray object by NSMutableArray *array = [[NSMutableArray alloc]init]; and used method
I am using this code in a loop to populate an NSMutable Array of
I have this code: var a:Array = [ Ramsey, Tusey, Iuser,Sephora,'user', 'reseo', 'nesey', 'sela']
Please look at this code: def chop(array, search): lo = 0 high = len(array)
So here's what I see this code doing: An array is made A loop
implementing publishActivity in PHP using the REST API using this code: $activity = array(

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.