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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:45:18+00:00 2026-06-15T17:45:18+00:00

I am working in Xcode 4.5.1 in Objective-C. I’m making a hearing test and

  • 0

I am working in Xcode 4.5.1 in Objective-C. I’m making a hearing test and want to store relevant data to each question in an array. I made a singleton MyManager. I use this to store data.

It is working fine for simple int/float values etc., but I’m stuck trying to use NSMutableArray. I’m new to Objective-C, so I’m assuming/hoping I’ve made some obvious mistake.

So, I want to fill mySNRArray with float values. I’ve come to understand that I can’t simply add floats, because it will only take objects. Thus, I use NSNumber.

Problem: When I try to read the data that I’ve supposedly added to the NSMutableArray, I get (null).

I will now provide the relevant code:

MyManager.h

@interface MyManager : NSObject
{

NSMutableArray *mySNRArray;

}

@property (readwrite) NSMutableArray *mySNRArray;

+ (id)sharedManager;

@end

MyManager.m

@implementation MyManager

@synthesize mySNRArray;

+ (id)sharedManager
{
static MyManager *sharedMyManager = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^
    {

            sharedMyManager = [[self alloc] init];

    });

return sharedMyManager;
}

- (id)init
{
if (self = [super init])
{

    NSMutableArray *mySNRArray = [[NSMutableArray alloc]init];

}

return self;
}

@end

TestViewController.m

//First, I try to add a value to mySNRArray.

MyManager *Manager = [MyManager sharedManager];

NSNumber *tempStorage1 = [[NSNumber alloc] initWithFloat:mySNR];

[Manager.mySNRArray insertObject:tempStorage1 atIndex:questionNumber];

//The NSLog below is showing the correct value.

NSLog(@"%@ : mySNR", tempStorage1);


...


for (n = 0; n < questionNumber; n++)
{

//Second, I try to acces the values I supposedly added to mySNRArray. 

MyManager *Manager = [MyManager sharedManager];

//This NSLog below is showing (null).

NSLog(@"Value at %i in SNRArray = %@", n, [Manager.mySNRArray objectAtIndex:n]);

}


...

I hope somebody can explain my error.

  • 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-15T17:45:19+00:00Added an answer on June 15, 2026 at 5:45 pm

    change

    NSMutableArray *mySNRArray = [[NSMutableArray alloc]init];
    

    to

    self->_mySNRArray = [[NSMutableArray alloc]init];
    

    in your init method you are creating a local mutable array, but not assigning it to your property

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

Sidebar

Related Questions

I'm learning Objective-C, noob question. I'm working on a project in Xcode that requires
I am working with Objective-C in Xcode. I was wondering is there any mechanism
I am working on a simple project in Objective-C in Xcode, and I'm getting
I am working on a little game (using OS X Lion, Xcode 4, Objective-C
I'm working with Objective-C and Xcode for about a year. I customise a lot
Very new to Objective-C and Xcode and working my way through modifying the DrillDownApp
I'm new to Objective C and XCode, currently working on my first iPhone Game.
Im working on an ios app, ios 5+ , using xcode and objective c.
While working with xcode, I saw a new line jmUIImage and i try to
I am working on xcode project intended to make a universal app.With the window

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.