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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:52:21+00:00 2026-06-18T00:52:21+00:00

I sometimes have trouble understanding iOS’s memory management. I took over some app and

  • 0

I sometimes have trouble understanding iOS’s memory management.

I took over some app and I’m developing it. App is developed under deployment target 4.3 and it cannot be changed due to client’s requirements.

There is a method that creates Picker.

NSMutableArray *arrayToLoad = [[NSMutableArray alloc] initWithObjects: obj, nil];
[arrayToLoad addObjectsFromArray: (NSMutableArray*)[valueArrays objectAtIndex: btn.tag]];
if( !picker )
{
    picker = [[WybierzZListyViewController alloc] initWithValues: arrayToLoad useObjectType: YES selectedIndex:0];
    [self.view addSubview: picker.view];
    picker.delegate = self;
    [picker animate];
}
else
{
    picker = [[WybierzZListyViewController alloc] initWithValues: arrayToLoad useObjectType: YES selectedIndex:0];
    [picker reuseWithValues: arrayToLoad useObjectType: YES selectedIndex: indexes[btn.tag]];
    [picker animate];
}

This else block, and especially method reuseWithValues causes me a lot of troubles and I’d most likely wipe it out.

Was the previous developer right about reusing previously created picker instead creating new one all over again? Sounds resoanable but makes few things hard for me later, and I was wondering if I could have just:

picker = [[WybierzZListyViewController alloc] initWithValues: arrayToLoad useObjectType: YES selectedIndex:0];
[self.view addSubview: picker.view];
picker.delegate = self;
[picker animate];

without else block, and avoiding memory leaks. Theoretically new ViewController should be allocated under picker variable, but what about replaced one. Should I somehow destroy it before I replace it?

  • 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-18T00:52:22+00:00Added an answer on June 18, 2026 at 12:52 am

    Try doing like this while initializing picker

        NSMutableArray *arrayToLoad = [[NSMutableArray alloc] initWithObjects: obj, nil];
            [arrayToLoad addObjectsFromArray: (NSMutableArray*)[valueArrays objectAtIndex: btn.tag]];
            if( !picker )
            {
    
    [picker.view removeFromSuperview];
    picker.delegate = nil;
    picker = nil
            }
                picker = [[WybierzZListyViewController alloc] initWithValues: arrayToLoad useObjectType: YES selectedIndex:0];
                [self.view addSubview: picker.view];
                picker.delegate = self;
                [picker animate];
    

    Hope this will solve your problem.

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

Sidebar

Related Questions

I have some trouble in my app where sometimes it works and displays all
I am currently working with Itextsharp and I have some trouble with PDfPtables. Sometimes
I have some trouble that comes from my Javascript (JS) codes, since I sometimes
I have some trouble with cmd.exe . I use it sometimes to create files
Sometimes I have to check for some condition that doesn't change inside a loop,
I'm having quite some trouble with the WCF Callback mechanism. They sometimes work but
I have trouble with some code I just wrote. Basically, this code is inside
I have a trouble with the following code. The program seems to stuck sometimes
I have an app that sometimes links to imdb. I can do this with
When using double click enable on any component, sometimes I have trouble activating the

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.