diff --git a/SOPE/NGCards/ChangeLog b/SOPE/NGCards/ChangeLog index 55ec998f4..75c6d547e 100644 --- a/SOPE/NGCards/ChangeLog +++ b/SOPE/NGCards/ChangeLog @@ -1,3 +1,8 @@ +2007-11-22 Wolfgang Sourdeau + + * iCalEntityObject.m ([iCalEntityObject -compare:otherObject]): + safely compare between objects which may be nil. + 2007-11-18 Wolfgang Sourdeau * iCalPerson.m ([-rsvp]): return lowercase string. diff --git a/SOPE/NGCards/iCalEntityObject.m b/SOPE/NGCards/iCalEntityObject.m index 53a51c1f6..45ac1f90c 100644 --- a/SOPE/NGCards/iCalEntityObject.m +++ b/SOPE/NGCards/iCalEntityObject.m @@ -425,13 +425,38 @@ return nil; /* not found */ } +- (NSComparisonResult) _compareValue: (id) selfValue + withValue: (id) otherValue +{ + NSComparisonResult result; + + if (selfValue) + { + if (otherValue) + result = [selfValue compare: otherValue]; + else + result = NSOrderedDescending; + } + else + { + if (otherValue) + result = NSOrderedAscending; + else + result = NSOrderedSame; + } + + return result; +} + - (NSComparisonResult) _compareVersions: (iCalEntityObject *) otherObject { NSComparisonResult result; - result = [[self sequence] compare: [otherObject sequence]]; + result = [self _compareValue: [self sequence] + withValue: [otherObject sequence]]; if (result == NSOrderedSame) - result = [[self lastModified] compare: [otherObject lastModified]]; + result = [self _compareValue: [self lastModified] + withValue: [otherObject lastModified]]; return result; }