-1
我以來自用戶的輸入字符串作爲,並希望將其存儲在數據格式,而打印回安慰它給我NULL
後...如何用戶輸入的字符串轉換爲NSDate的對象
這裏是我做過什麼:
MyLog(@"\nPlease Enter Date");
scanf("%s",cDate);
stringDate= [NSString stringWithCString:cDate encoding:1];
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"dd-MM-yyyy"];
NSDate * incomeDate = [dateFormat dateFromString:sDate];
MyLog(@"Date Entered is %@",[dateFormat stringFromDate:incomeDate]);
我想應該是的NSDate * incomeDate = [DATEFORMAT dateFromString:stringDate]。 – 2014-09-13 06:34:32
不是** sDate **應該是*** stringDate ***或者反之亦然? – 2014-09-13 06:38:41