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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:51:50+00:00 2026-05-22T02:51:50+00:00

I would need some expert advice on how to solve this problem. I am

  • 0

I would need some expert advice on how to solve this problem. I am doing some crude testing for a new app for the iPad.

I create a NSMutableArray (ballPath) in the viewDidLoad of my view controller (it is declared in my .h file) by loading a plist file created in another app.

ballPath = [[NSMutableArray alloc] initWithCapacity:1000];

NSString *path=[[NSBundle mainBundle] pathForResource:@"level_1" ofType:@"plist"];

ballPath = [NSKeyedUnarchiver unarchiveObjectWithFile:path];

This array now contains a number of CGPoints (stored by the other app as NSValues and the archived).

enter image description here

I then draw the path (still in my viewDidLoad), which works fine, so the path should work fine.

When I later on want to read the array as a response to changes in acceleration, I get an EXC_BAD_ACCESS. When I debug and look at my array it looks like this:

enter image description here

I test and replace the loaded array with this (also in viewDidLoad):

    ballPath = [[NSMutableArray alloc] initWithObjects:
            [NSValue valueWithCGPoint:CGPointMake(100.0, 100.0)],
            [NSValue valueWithCGPoint:CGPointMake(100.0, 200.0)],
            [NSValue valueWithCGPoint:CGPointMake(100.0, 300.0)],
            [NSValue valueWithCGPoint:CGPointMake(100.0, 400.0)],
            [NSValue valueWithCGPoint:CGPointMake(125.0, 450.0)],
            [NSValue valueWithCGPoint:CGPointMake(150.0, 500.0)],
            [NSValue valueWithCGPoint:CGPointMake(300.0, 600.0)],
            [NSValue valueWithCGPoint:CGPointMake(350.0, 550.0)],nil];

Then it works just fine!

enter image description here

What am I missing here????

I’m on Xcode 4.0.2 and my target is iOS 4.3.

  • 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-22T02:51:51+00:00Added an answer on May 22, 2026 at 2:51 am

    The array is deallocated at that point, so that there’s some random memory where the array previously was.

    unarchiveObjectWithFile: returns an autoreleased object, if you want to keep the array around, you need to retain it (or make it a retained property). The alloc-init two lines earlier is completely superfluous (and probably leaks memory), because you’re never doing anything with the array you create there, it is replaced by the array you load from the bundle.

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

Sidebar

Related Questions

I need to solve a job affectation problem and I would like to find
I would need some basic vector mathematics constructs in an application. Dot product, cross
I need to do some process injection using C++ but I would prefer to
I need to make some commits using Git but I would like the timestamp
I need to generate random text strings of a particular format. Would like some
still new to the world of linq, and i need some help flatening a
I would need to create a temp table for paging purposes. I would be
What regex pattern would need I to pass to java.lang.String.split() to split a String
Does anyone know what would be the minimum rights I would need to grant
I'm working on a tool which would need to communitacte: send and recieve files

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.