访问UIDatePicker时为EXC

访问UIDatePicker时为EXC

我想从DatePicker中读取值并将其存储在我的单例中,但是在尝试执行此操作时出现异常。

这是单例界面:

@interface Helper : NSObject {
NSMutableArray *array;
//Information For Filter page
NSMutableArray *towns;
NSMutableArray *types;
//Shared resources to apply filters
NSDate *toDate;
NSDate *fromDate;
NSString *selectedType;
NSString *selectedTown;
//Shared resource of which button was clicked
int clicked;
int clickedCell;
int clickedContext;
}
@property (nonatomic, retain) NSMutableArray *array;
@property (nonatomic, retain) NSMutableArray *towns;
@property (nonatomic, retain) NSMutableArray *types;
@property (nonatomic) int clicked;
@property (nonatomic) int clickedCell;
@property (nonatomic) int clickedContext;
@property (nonatomic, retain) NSDate *toDate;
@property (nonatomic, retain) NSDate *fromDate;
@property (nonatomic, retain) NSString *selectedType;
@property (nonatomic, retain) NSString *selectedTown;

+(id)sharedManager;


@end


这是发生异常的功能

-(void) viewWillDisappear:(BOOL)animated
{

Helper *myHelper = [Helper sharedManager];
if(myHelper.clickedContext == 0)
{
    if(myHelper.clickedCell == 0)
    {
        //causes exception
        myHelper.fromDate = [self.fromDatePicker date];
    }
    else
    {
        //causes exception
        myHelper.toDate = [self.toDatePicker date];
    }
}
else
{
    if(myHelper.clickedCell == 0)
    {
        myHelper.selectedTown = [myHelper.towns objectAtIndex:[self.townPicker selectedRowInComponent:0]];
    }
    else
    {
        myHelper.selectedType = [myHelper.types objectAtIndex:[self.typePicker selectedRowInComponent:0]];
    }
}
[super viewWillDisappear:animated];
}


采摘者声明

@property (nonatomic, retain) IBOutlet UIDatePicker *toDatePicker;
@property (nonatomic, retain) IBOutlet UIDatePicker *fromDatePicker;
@property (nonatomic, retain) IBOutlet UIPickerView *typePicker;
@property (nonatomic, retain) IBOutlet UIPickerView *townPicker;


@synthesize部分

@synthesize typePicker, toDatePicker, fromDatePicker, townPicker, townsView, toDateView, typesView, fromDateView;


知道为什么吗?

谢谢

最佳答案

如果您的插座未在界面构建器中分配,则可能会发生这种情况。

如果您认为是这样,请尝试使用NSZombieEnabled = YES运行该应用程序,然后查看是否收到任何错误消息。

关于iphone - 访问UIDatePicker时为EXC_BAD_ACCESS,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6748662/

10-09 01:23