From 763ce37f8cc7ff98b4cdacd79c51759e4d948f95 Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Wed, 1 Jul 2015 14:09:12 -0400 Subject: [PATCH] Allow multiple "attach" values in iCalEntityObject --- SOPE/NGCards/iCalEntityObject.h | 4 +-- SOPE/NGCards/iCalEntityObject.m | 47 ++++++++++++++++++++++----------- 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/SOPE/NGCards/iCalEntityObject.h b/SOPE/NGCards/iCalEntityObject.h index 0fd9dc4f2..3dcb25a00 100644 --- a/SOPE/NGCards/iCalEntityObject.h +++ b/SOPE/NGCards/iCalEntityObject.h @@ -94,8 +94,8 @@ typedef enum - (void) increaseSequence; /* url can either be set as NSString or NSURL */ -- (void) setAttach: (id) _value; -- (NSURL *) attach; +- (void) setAttach: (NSArray *) _value; +- (NSArray *) attach; - (void) setUrl: (id) _value; - (NSURL *) url; diff --git a/SOPE/NGCards/iCalEntityObject.m b/SOPE/NGCards/iCalEntityObject.m index b10fb301b..5c5af1859 100644 --- a/SOPE/NGCards/iCalEntityObject.m +++ b/SOPE/NGCards/iCalEntityObject.m @@ -400,32 +400,49 @@ return [self childrenWithTag: @"valarm"]; } -- (void) setAttach: (id) _value +- (void) setAttach: (NSArray *) _value { NSString *aString; + id anObject; + int count, max; - if ([_value isKindOfClass: [NSString class]]) - aString = _value; - else if ([_value isKindOfClass: [NSURL class]]) - aString = [_value absoluteString]; - else - aString = @""; - - [[self uniqueChildWithTag: @"attach"] setSingleValue: aString forKey: @""]; + max = [_value count]; + for (count = 0; count < max; count++) + { + anObject = [_value objectAtIndex: count]; + if ([anObject isKindOfClass: [NSURL class]]) + { + aString = [anObject absoluteString]; + } + else + aString = anObject; + [self addChild: [CardElement simpleElementWithTag: @"attach" value: aString]]; + } } -- (NSURL *) attach +- (NSArray *) attach { + NSArray *elements; + NSMutableArray *attachUrls; NSString *stringAttach; NSURL *url; + int count, max; - stringAttach = [[self uniqueChildWithTag: @"attach"] flattenedValuesForKey: @""]; - url = [NSURL URLWithString: stringAttach]; + elements = [self childrenWithTag: @"attach"]; + max = [elements count]; + attachUrls = [NSMutableArray arrayWithCapacity: max]; + for (count = 0; count < max; count++) + { + stringAttach = [[elements objectAtIndex: count] flattenedValuesForKey: @""]; + url = [NSURL URLWithString: stringAttach]; - if (!url && [stringAttach length] > 0) - url = [NSURL URLWithString: [NSString stringWithFormat: @"http://%@", stringAttach]]; + if (!url && [stringAttach length] > 0) + url = [NSURL URLWithString: [NSString stringWithFormat: @"http://%@", stringAttach]]; + + [attachUrls addObject: [url absoluteString]]; + } - return url; + return attachUrls; } - (void) setUrl: (id) _value