我從我的服務器,我把一個NSDictionary recing 3字符串值。然後我將這些值傳遞給一個NSDateComponent之後我嘗試創建一個NSDateFormatter,我很確定這是錯誤的。NSDate到NSString錯誤
的日期甲應該是01月2014,我recive是這樣
{
Day @"1"
Month @"4"
Year @"2014"
}
在下面的代碼,你會看到我都試過,但是我是這樣做的數據在兩個區域遇到問題,格式化爲NSDateFormatter,其次我如何將日期傳遞到NSString中,以便我可以將其顯示在我的標籤中。
NSDateComponents *recivedDate = [[NSDateComponents alloc] init];
[recivedDate setDay:[[recivedData objectForKey:@"Day"] intValue]];
[recivedDate setMonth:[[recivedData objectForKey:@"Month"] intValue]];
[recivedDate setYear:[[recivedData objectForKey:@"Year"] intValue]];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"dd-mm-yyy"];
NSString *dateString = [formatter stringFromDate:recivedDate];
dateResultLabel.text = dateString;
任何幫助,將不勝感激。
你會在recivedDate中得到什麼? –
不應該是[formatter setDateFormat:@「dd-MM-yyyy」]; ? – Rashad