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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:42:35+00:00 2026-06-14T10:42:35+00:00

i have an array of custom class that is allocated in this way :

  • 0

i have an array of custom class that is allocated in this way :

myArray = [NSMutableArray array];

I add object in it though a for loop :

for (CustomClass *obj in otherArray) {
    [myArray addObject:obj];
}

Then, i add all to my view :

CustomClass *obj = [myArray objectAtIndex:index];
[self.view addSubview:obj];

Every time i add the element in view i remove it from the array :

[myArray removeObject:obj];

At the end i have all the elements in my view. But, at the end of the game, i have to remove all objects from my view and remove also from memory. I use ARC.
I don’t know how to release objects also from memory.
Thanks

  • 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-14T10:42:37+00:00Added an answer on June 14, 2026 at 10:42 am

    You will have to remove the object from every places it’s stocked. ARC will handle for you the retain / release calls (at compile) to fall to zero when unused. You should notice that unreferenced object will no matter what be deallocated.

    So you just have to keep in mind where your object is referenced :

    Array

    When you add it into myArray it adds 1 to retain count.

    When you remove it removes 1.

    View

    When you addSubview it adds 1.

    When you want to remove from super view you should call the removeFromSuperview selector on your item (I guess you know it and this isn’t your question)

    First Array

    I noticed it’s your objects always stay in the otherArray array.

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

Sidebar

Related Questions

I have a custom class of type NSObject that contains a single NSMutableArray. This
I have a custom class MDRect that i am trying to add an NSMutableArray
I have this function in my custom dynamic array class that allows the user
I have a custom object that I was adding to an array via a
I have an array that contains a custom class of mine called 'Game'. Each
I have a method that returns an array of custom class objects that are
So i have this class that includes some custom functions named class.php I have
I have an array of custom class Student objects. CourseStudent and ResearchStudent both inherit
I have an array (items) of custom class objects (catalogItem) each catalogItem has various
I have a class with a custom each-method: class CurseArray < Array def each_safe

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.