为什么这个NSMutableArray没有填充?

时间:2010-08-27 01:38:55

标签: iphone objective-c nsmutablearray uipickerview

我有一个NSMutableArray我正在尝试使用for-loop填充并为其NSStrings填充。这些是我UIPickerView的数据源。你会看到一些注释掉的行,我手动制作NSArrays并且它们显示正常,但我的for-loop NSMutableArray似乎不接受我正在制作的字符串。 NSLogs显示我正在制作字符串(以及等效的float),但从NSLogs中提取值的NSMutableArray显示为{{1} }和null

界面......


0.0

实施......


//  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

1 个答案:

答案 0 :(得分:3)

您是否在某处初始化阵列?我在任何地方都看不到[[NSMutableArray alloc] init]。将消息发送到空对象是一个无操作,因此很可能这些addObjects被发送到null并且没有做任何事情。