OLD DATE: 2011-04-06 10:58:43 +0000
NEW DATE: 2011-04-06 10:58:43 +0000
ฉันต้องเปรียบเทียบสองวันนี้ เมื่อสิ่งใหม่ยิ่งใหญ่กว่าเก่าสิ่งนี้สำคัญสำหรับฉัน แต่ฉันมีปัญหารหัสของฉันมักจะอยู่ในบล็อกโค้ดเปรียบเทียบนั้น ดังนั้นตัวอย่างวันที่ข้างต้นจึงแตกต่างกันไปตามแอปพลิเคชันของฉัน แต่เหมือนกัน ฉันไม่เข้าใจว่าฉันได้รับผลลัพธ์ที่ผิดที่นี่ได้อย่างไร นี่คือรหัส:
Something *existing;
for(existing in exisingDatabaseItems)
{
Something *newFromWebService;
for(newFromWebService in WSArray)
{
if(existing.SomethingId == newFromWebService.SomethingId)
{
if([existing.LastModifiedOnDate compare:newFromWebService.LastModifiedOnDate] == NSOrderedAscending)
{
// It always get in here???
NSLog(@"OLD: %@", existing.LastModifiedOnDate);
NSLog(@"NEW: %@", newFromWebService.LastModifiedOnDate);
break;
}
}
}
}
existing.LastModifiedOnDate = newFromWebService.LastModifiedOnDate
? - person Lepidopteron   schedule 06.04.2011