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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:08:49+00:00 2026-06-10T04:08:49+00:00

In my game, I allocate some UIImageViews programmatically with the following code: blocks[1] =

  • 0

In my game, I allocate some UIImageViews programmatically with the following code:

blocks[1] = [[UIImageView alloc] initWithFrame: CGRectMake(200, y1, kBlockHeight, kBlockHeight)];
blocks[2] = [[UIImageView alloc] initWithFrame: CGRectMake(320, y2, kBlockHeight, kBlockHeight)];
blocks[3] = [[UIImageView alloc] initWithFrame: CGRectMake(440, y3, kBlockHeight, kBlockHeight)];
blocks[4] = [[UIImageView alloc] initWithFrame: CGRectMake(560, y4, kBlockHeight, kBlockHeight)];

blocks[1].backgroundColor = [UIColor blackColor];
blocks[2].backgroundColor = [UIColor blackColor];
blocks[3].backgroundColor = [UIColor blackColor];
blocks[4].backgroundColor = [UIColor blackColor];

[self.view addSubview: blocks[1]];
[self.view addSubview: blocks[2]];
[self.view addSubview: blocks[3]];
[self.view addSubview: blocks[4]];

and it works fine, but when I try to get rid of the objects and restart,

for (int i = 1; i<= 4; i++) {
    blocks[i] = nil;
    //ARC won't let me call [blocks[i] release];
    NSLog(@"releasing blocks");
}

they still stay on the screen. They don’t interact with anything, but still stay drawn on the screen. Why is this, and what should I do to get rid of the objects?

  • 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-10T04:08:50+00:00Added an answer on June 10, 2026 at 4:08 am

    Your UIImageViews are still being retained by your viewController’s view. Try using:

    for (int i = 1; i<= 4; i++) {
        [blocks[i] removeFromSuperview];
        blocks[i] = nil;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Permutation Game (30 Points) Alice and Bob play the following game: 1) They choose
Way way back (think 20+ years) I encountered a Gomoku game source code in
Ahoy! I've been looking into updating some old test code in an attempt to
I am developing some utilities to control threading for a game server and am
I'm learning andEngine and trying to make a simple game based on some examples.
How is the following class Game abstract? And how do I make it concrete
I am developing a game using Cocos2D for iOS. There are some scenes like
I'm profiling code of a game I wrote and I'm wondering how it is
My game units have an angle variable, and a targetAngle variable. These variables range
My game is a small shooting game in cocos2d. The enemy generates the bullets

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.