Actually My code is:
else if(isExpense == YES)
{
NSDate *strDate;
strDate = [NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
[dateFormatter setDateFormat:@"dd-MM-yyyy"];
if([expense.date length] > 0)
{
NSDate *date = [dateFormatter dateFromString:expense.date];
datePicker.date = date; //Here date value is passing nil and Im getting Exception
}
else
{
开发者_如何学Go datePicker.date = strDate;
}
}
Guys can anyone help to get out of this problem?????
Anyone's help will be much appreciated.
Thank You, Kiran.
What type is expense.date? Because NSDate doesn't have a length method. And if expense.date is a NSString
[dateFormatter dateFromString:expense.date];
will not return a valid date, because it expects a NSDate as parameter.
精彩评论