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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:27:26+00:00 2026-05-25T02:27:26+00:00

I’ve written an app with a custom Search class in it. This builds up

  • 0

I’ve written an app with a custom Search class in it. This builds up an array of results.

I then assign that array into my FirstViewController class, and reload a table view which has the results array assigned to it

self.aResults = [thisSearch.aResults copy]
...
[[self searchResults] reloadData];

Shortly after doing that I’m releasing thisSearch

[thisSearch release];

This all works fine, and shows the the results table, but if I scroll down the table and look at the rows below they are all blank, then as I scroll back up the app crashes when it reloads the recycled table cells.

This wasn’t happening to me before, but I realised I was leaking memory, so I went autorelease crazy, and added lots of autorelease to my Search class. But not my FirstViewController class.

So if I use Copy, does it not actually make a copy of the object, does it just increase the reference counter? So when I destroy Search, am I destroying the results array in there, and therefore destroying what the FirstViewController is trying to access for the table view?

Sorry if that doesn’t make much sense, I’m not feeling very with it today.

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

    When you copy objects (and to do so that object must conform to the NSCopying Protocol but that’s the case of NSArray) it is exactly as if you were initializing it for the first time with predifined values.

    So it is your responsability to release objects that have been copied.

    Thefore you must do :

    self.aResults = [thisSearch.aResults copy]
    ...
    
    [thisSearch release]; // When you release thisSearch this will not affect aResults
    ...
    
    // then you can either do:
    [self.aResults autorelease]; // but then do not release it later on
    // or
    [self.aResults release]; // when you're done with it
    

    However I doubt this will solve you memory issues. By over autoreleasing (and still releasing things) you might have completely corrupted your application memory management.

    To try to fix it, try to analyze your project and see what comes up.

    enter image description here

    Also I attach the Apple Memory Management link that one should read monthly until it becomes second nature.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I am currently running into a problem where an element is coming back from
We're building an app, our first using Rails 3, and we're having to build

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.