你可以檢查字符串爲「T」或「+」給了你肯定知道這些是僅有的3種可能性:
NSString *dateString = @"2013-01-13T11:00:00";
if (([dateString rangeOfString:@"T"].location != NSNotFound) && ([dateString rangeOfString:@"+"].location != NSNotFound)) {
NSLog(@"found T and + in dateString: %@", dateString);
//set date format accordingly...
} else if (([dateString rangeOfString:@"T"].location != NSNotFound) && ([dateString rangeOfString:@"+"].location == NSNotFound)) {
NSLog(@"only found T in dateString: %@", dateString);
//set date format accordingly...
} else {
NSLog(@"didn't find T or + in dateString: %@", dateString);
//set date format accordingly...
}
不得不修復我的代碼。這應該現在工作。 – jhilgert00
謝謝jhilgert00 –