开发者

Problem in dateFormatter in Iphone sdk?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜