NSMutableOrderedSet decodes to NSOrderedSet when using NSCoder

Originator:getaaron
Number:rdar://13219056 Date Originated:14-Feb-2013 04:58 PM
Status:Open Resolved:
Product:iPhone SDK Product Version:6.1
Classification:Serious Bug Reproducible:Always
 
Sample project can be downloaded here:  http://cl.ly/1P2c0d1m3q15

Summary:

When a NSMutableOrderedSet object is encoded, and then decoded using NSCoder, it is decoded as the wrong object type.

Steps to Reproduce:

// need to define path and error

NSMutableOrderedSet *mutableSet = [[NSMutableOrderedSet alloc] init];
[mutableSet addObject:@"test"];

NSData *archiveData = [NSKeyedArchiver archivedDataWithRootObject:mutableSet];
[archiveData writeToFile:path options:NSDataWritingAtomic error:&error];

NSData *archiveData2 = [fileManager contentsAtPath:path];
NSMutableOrderedSet *mutableSet2 = [NSKeyedUnarchiver unarchiveObjectWithData:archiveData2];

[mutableSet2 addObject:@"test 2"];  //throws exception because mutableSet2 is immutable

Expected Results:

Either decode the object in the same type that was archived, or display a warning when assigning the results to a mutable object.

Actual Results:

No indication of failure

Exception thrown when attempting to mutate object

Regression:

Unknown

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!