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

  • Home
  • SEARCH
  • 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 1021691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:20:54+00:00 2026-05-16T11:20:54+00:00

I have an NSMutableArray I am trying to populate using a for-loop and making

  • 0

I have an NSMutableArray I am trying to populate using a for-loop and making NSStrings for it. These are to be the data source for my UIPickerView. You’ll see some commented out lines where I manually made NSArrays and they showed up fine, but my for-loop NSMutableArray doesn’t seem to accept the strings I’m making. The NSLogs show that I am making the string (and an equivalent float) alright, but the NSLogs that pull the values from the NSMutableArray show up as null and 0.0

The interface…


//  PoolSizePickerViewController.h

#import <UIKit/UIKit.h>
#define kLengthComponent 0
#define kWidthComponent 1
#define kDepthComponent 2

@protocol PoolSizePickerViewControllerDelegate;

@interface PoolSizePickerViewController : UIViewController <UIPickerViewDelegate, UIPickerViewDataSource> {
    UIPickerView *poolSizePicker;
    float length, width, depth;
    NSMutableArray *lengthStrings, *widthStrings, *depthStrings;
    NSMutableArray *lengthFloats, *widthFloats, *depthFloats;
    NSString *pickerType;
    NSString *pickerDescription;
    UIButton *selectButton;
    UIButton *cancelButton;
    UILabel *pickerTitleLabel;
    UITextView *pickerDescriptionLabel;
    id <PoolSizePickerViewControllerDelegate> delegate;
}

@property (nonatomic, retain) IBOutlet UIPickerView *poolSizePicker;
@property float length, width, depth;
@property (nonatomic, retain) NSMutableArray *lengthStrings, *widthStrings, *depthStrings;
@property (nonatomic, retain) NSMutableArray *lengthFloats, *widthFloats, *depthFloats;
@property (nonatomic, retain) NSString *pickerType;
@property (nonatomic, retain) NSString *pickerDescription;
@property (nonatomic, retain) IBOutlet UIButton *selectButton;
@property (nonatomic, retain) IBOutlet UIButton *cancelButton; 
@property (nonatomic, retain) IBOutlet UILabel *pickerTitleLabel;
@property (nonatomic, retain) IBOutlet UITextView *pickerDescriptionLabel;
@property (assign) id <PoolSizePickerViewControllerDelegate> delegate;

- (IBAction)selectedSelectButton;
- (IBAction)selectedCancelButton;

@end

@protocol PoolSizePickerViewControllerDelegate <NSObject>

@optional

- (void)poolSizePickerViewController:(PoolSizePickerViewController *)controller 
                 didSelectLength:(float)length
                        andWidth:(float)width 
                        andDepth:(float)depth;

- (void)poolSizePickerViewController:(PoolSizePickerViewController *)controller 
               didSelectCancel:(BOOL)didCancel;

@end

And the implementation…


//  PoolSizePickerViewController.m

#import "PoolSizePickerViewController.h"

@implementation PoolSizePickerViewController

@synthesize poolSizePicker;
@synthesize length, width, depth;
@synthesize lengthStrings, widthStrings, depthStrings;
@synthesize lengthFloats, widthFloats, depthFloats;
@synthesize delegate;
@synthesize pickerType, pickerDescription;
@synthesize selectButton, cancelButton;
@synthesize pickerTitleLabel;
@synthesize pickerDescriptionLabel;

- (IBAction)selectedSelectButton {
    NSInteger lengthRow = [poolSizePicker selectedRowInComponent:kLengthComponent];
    NSInteger widthRow = [poolSizePicker selectedRowInComponent:kWidthComponent];
    NSInteger depthRow = [poolSizePicker selectedRowInComponent:kDepthComponent];
    length = [[self.lengthFloats objectAtIndex:lengthRow] floatValue];
    width = [[self.widthFloats objectAtIndex:widthRow] floatValue];
    depth = [[self.depthFloats objectAtIndex:depthRow] floatValue];
    if ([self.delegate respondsToSelector:@selector (poolSizePickerViewController:didSelectLength:andWidth:andDepth:)]) {
        [self.delegate poolSizePickerViewController:self didSelectLength:length andWidth:width andDepth:depth];
    }
}

- (IBAction)selectedCancelButton {
    if ([self.delegate respondsToSelector:@selector (poolSizePickerViewController:didSelectCancel:)]) {
        [self.delegate poolSizePickerViewController:self didSelectCancel:YES];
    }
}


- (void)viewDidLoad {
    for (int footIndex = 6; footIndex < 40; footIndex ++) {
        for (int inchIndex = 0; inchIndex < 2; inchIndex ++) {
            [self.lengthStrings addObject:[NSString stringWithFormat:@"   %d' %d\"", footIndex, inchIndex * 6]];
            NSLog(@"   %d' %d\"", footIndex, inchIndex * 6);
            NSLog(@"   -%@", [self.lengthStrings objectAtIndex:footIndex - 6]);
            [self.lengthFloats addObject:[NSNumber numberWithFloat:(float)footIndex + (float)inchIndex * 0.5f]];
            NSLog(@"   %1.1f", (float)footIndex + (float)inchIndex * 0.5f);
            NSLog(@"   -%1.1f", [[self.lengthFloats objectAtIndex:footIndex - 6] floatValue]);
        }
    }
    for (int footIndex = 6; footIndex < 40; footIndex ++) {
    for (int inchIndex = 0; inchIndex < 2; inchIndex ++) {
            [self.widthStrings addObject:[NSString stringWithFormat:@"   %d' %d\"", footIndex, inchIndex * 6]];
            [self.widthFloats addObject:[NSNumber numberWithFloat:(float)footIndex + (float)inchIndex * 0.5f]];
        }
    }
    for (int footIndex = 1; footIndex < 16; footIndex ++) {
        for (int inchIndex = 0; inchIndex < 2; inchIndex ++) {
            [self.depthStrings addObject:[NSString stringWithFormat:@"   %d' %d\"", footIndex, inchIndex * 6]];
            [self.depthFloats addObject:[NSNumber numberWithFloat:(float)footIndex + (float)inchIndex * 0.5f]];
        }
    }

//  lengthStrings = [NSArray arrayWithObjects:@"   6' 0\"", nil];
//  lengthFloats = [NSArray arrayWithObjects:[NSNumber numberWithFloat:1.0], nil];
//  widthStrings = [NSArray arrayWithObjects:@"   6' 0\"", nil];
//  widthFloats = [NSArray arrayWithObjects:[NSNumber numberWithFloat:2.0], nil];
//  depthStrings = [NSArray arrayWithObjects:@"   1' 0\"", nil];
//  depthFloats = [NSArray arrayWithObjects:[NSNumber numberWithFloat:3.0], nil];

    UIImage *buttonImageNormal = [UIImage imageNamed:@"whiteButton.png"];
    UIImage *stretchableButtonImageNormal = [buttonImageNormal stretchableImageWithLeftCapWidth:12 topCapHeight:0];
    [selectButton setBackgroundImage:stretchableButtonImageNormal forState:UIControlStateNormal];
    [cancelButton setBackgroundImage:stretchableButtonImageNormal forState:UIControlStateNormal];
    UIImage *buttonImagePressed = [UIImage imageNamed:@"blueButton.png"];
    UIImage *stretchableButtonImagePressed = [buttonImagePressed stretchableImageWithLeftCapWidth:12 topCapHeight:0];
    [selectButton setBackgroundImage:stretchableButtonImagePressed forState:UIControlStateHighlighted];
    [cancelButton setBackgroundImage:stretchableButtonImagePressed forState:UIControlStateHighlighted];
    pickerTitleLabel.text = [NSString stringWithFormat:@"Select a Pool %@", pickerType];
    pickerDescriptionLabel.text = self.pickerDescription;
    self.poolSizePicker.showsSelectionIndicator = YES;
    [super viewDidLoad];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

- (void)viewDidUnload {
    [super viewDidUnload];
}

- (void)dealloc {
    [super dealloc];
}

   #pragma mark -
   #pragma mark Picker Data Source Methods

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
return 3;
}

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
    switch (component) {
        case kLengthComponent:
            return [self.lengthStrings count];
            break;
        case kWidthComponent:
            return [self.widthStrings count];
            break;
        default:
            return [self.lengthStrings count];
            break;
    }
}

#pragma mark Picker Delegate Methods

- (NSString *)pickerView:(UIPickerView *)pickerView
         titleForRow:(NSInteger)row
        forComponent:(NSInteger)component {
    switch (component) {
        case kLengthComponent:
            return [self.lengthStrings objectAtIndex:row];
            break;
        case kWidthComponent:
            return [self.widthStrings objectAtIndex:row];
            break;
        default:
            return [self.depthStrings objectAtIndex:row];
            break;
    }
}

@end
  • 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-16T11:20:54+00:00Added an answer on May 16, 2026 at 11:20 am

    Are you initializing your arrays somewhere? I don’t see an [[NSMutableArray alloc] init] anywhere. Sending a message to a null object is a no-op, so it’s likely that those addObjects are being sent to a null and aren’t doing anything.

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

Sidebar

Ask A Question

Stats

  • Questions 505k
  • Answers 505k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I really don't know what was so hard about this… May 16, 2026 at 3:29 pm
  • Editorial Team
    Editorial Team added an answer Replace the float with overflow: auto in .wrapper and it… May 16, 2026 at 3:29 pm
  • Editorial Team
    Editorial Team added an answer Because that ol li.blah a selector is true for all… May 16, 2026 at 3:29 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have an NSMutableArray that I'm trying to store and access some structs. How
Im making an app for the iphone using cocos2d and i am trying to
I need some help! Please. I am trying to develop a very very simple
I have a core data based app I am working on, that uses an
I'm trying to populate a UITableview with an array of cells. I usually do
i have 2 NSMutableArray with same type. i want to add second nsmutablearray to
I have an NSMutableArray which holds the dates in format dd/MM/yyyy of type NSString.
I have an NSMutableArray of Sprites and I want to remove a few of
If I have a NSMutableArray: NSMutableArray *principalTable; and I have a other NSMutableArray: NSMutableArray
I have an object called Station in my system with these attributes: @interface Station

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.