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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:19:33+00:00 2026-05-26T00:19:33+00:00

At the top of my .m file I have static NSMutableArray *name; I load

  • 0

At the top of my .m file I have

static NSMutableArray *name;

I load a bunch of values into my *name array inside my viewDidLoad method.

I have a slider that can modify the values inside this array. The slider method is only called when the value of the slider changes. However, I ran this code and every time my program exits the viewDidLoad method I lose the values that were added to the global variable name. I can see that they were there before exiting the viewDidLoad method.

What am I doing wrong?

EDIT: Inside viewDidLoad

if (name == nil)
    name = [NSMutableArray array];
UITextField *nameTemp = [[UITextField alloc] initWithFrame:CGRectMake(20,20,20,20)];
nameTemp.returnKeyType = UIReturnKeyDone;
etc
[self.view addSubview: nameTemp];
[name addObject:nameTemp]
[nameTemp release];
  • 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-26T00:19:34+00:00Added an answer on May 26, 2026 at 12:19 am

    [NSMutableArray array] creates an autoreleased array that apparently is being released at the end of your viewDidLoad method. Try using [[NSMutableArray alloc] init] or [[NSMutableArray array] retain] and see if the values persist after viewDidLoad returns.

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

Sidebar

Related Questions

I have a static class and inside that class images are loaded into BufferedImage
I have a linker command file that assigns the top address of the stack
I have this factory method in java: public static Properties getConfigFactory() throws ClassNotFoundException, IOException
I have a bunch of strings in my resource(.resx) file. I am trying to
I have a assets file that embeds things, [Embed(source='assets.swf', symbol='block')] public static const SYM_BLOCK:Class;
I'm new to flash, actionscript, and the class/method/static/instance paradigm. I do have one class
I have a program that generates a static HTML file. I have a list
I have this code in a xml layout file: <reference name=left> <block type=blog/blog name=left.blog.menu
I have a static file that I don't want to be publicly available. Is
PEP 8 states: Imports are always put at the top of the file, just

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.