TheProjecter / objectiveflickr

Automatically exported from code.google.com/p/objectiveflickr
Other
0 stars 0 forks source link

flickrDictionaryFromDocument discards one of multi-element values #1

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Steps to reproduce:
1. [invoc flickr_interestingness_getList:nil page:@"1" per_page:@"2" 
selector:@selector(handleGetList:errorCode:data:)];
2. in handleGetList print both the XML document as well as the length of the 
"photos.photo" 
array (NSArray *photos = [theDictionary valueForKeyPath:@"photos.photo"];)

Expected result:
The length of the photos array is equal to the number of <photo> elements in 
the XML.

Actual result:
The XML clearly contains two <photo> elements. The length of photos array is 1.
This appears to happen for every response with multiple elements with the same 
name.

From my reading the else-branch in OFFlickrXMLExtension.m overwrites the 
already existing 
object with the same name with an array of 1 discarding the old element:
                // it's already an array
                if ([obj isKindOfClass:[NSMutableArray class]]) {
                    [obj addObject:[n flickrDictionaryFromNode]];
                }
                else {
                    NSMutableArray *a = [NSMutableArray arrayWithObject:obj];
                    [d setObject:a forKey:name];
                }

Shouldn't that be:
                // object exists but it's not yet an array
                if (![obj isKindOfClass:[NSMutableArray class]]) {
                    NSMutableArray *a = [NSMutableArray arrayWithObject:obj];
                    [d setObject:a forKey:name];
                }
                [obj addObject:[n flickrDictionaryFromNode]];

What version of the product are you using? On what operating system?
ObjectiveFlickr 0.9.5

Please provide any additional information below.
http://www.flickr.com/services/api/flickr.interestingness.getList.html

Original issue reported on code.google.com by tkomu...@gmail.com on 7 Apr 2007 at 12:25

GoogleCodeExporter commented 9 years ago

Original comment by lukh...@gmail.com on 7 Apr 2007 at 1:02

GoogleCodeExporter commented 9 years ago
This issue is tested and confirmed. It's a serious problem, and I really 
appreciate that you have pointed it out. 
The patched code has already been commited into the trunk, and a binary package 
should be released shortly.

This only affects programs that depend on OFFlickrXMLExtension.

Original comment by lukh...@gmail.com on 16 Apr 2007 at 1:47

GoogleCodeExporter commented 9 years ago

Original comment by lukh...@gmail.com on 16 Apr 2007 at 1:48