访问UIDatePicker时的EXC_BAD_ACCESS [英] EXC_BAD_ACCESS when accessing UIDatePicker

查看:78
本文介绍了访问UIDatePicker时的EXC_BAD_ACCESS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I want to read the value from my DatePicker and store it in my singleton, but I get an exception when trying to do this.

这是单例界面:

@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 part

@synthesize part

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

任何想法都是为什么?

谢谢

推荐答案

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

If your outlet is not assigned in interface builder this can happen.

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

If you think it is, try running the app with NSZombieEnabled = YES and see if you get any error messages.

这篇关于访问UIDatePicker时的EXC_BAD_ACCESS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆