From 68b4fe07be3d73aea37015b6fbf6fb354cc8d088 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Thu, 22 Nov 2007 16:19:11 +0000 Subject: [PATCH] Monotone-Parent: a2e22f9ca9e5096f59327f5b4d176050ffcbf15f Monotone-Revision: 00622e0c5fa34a4e5e98835bf4037dc6f562e342 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-11-22T16:19:11 Monotone-Branch: ca.inverse.sogo --- SOPE/NGCards/ChangeLog | 5 +++++ SOPE/NGCards/iCalEntityObject.m | 29 +++++++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) 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; }