Fixed: CPOutlineView could not be archived with CPCoding. Closes #1093.

This fixes the exception "[_CPOutlineViewTableViewDataSource encodeWithCoder:] unrecognized selector sent to instance".
This commit is contained in:
Alexander Ljungberg committed 2011-01-13 22:18:05 -03:00
1 parent 31ac84f683
commit 2a27a87ae6
2 files changed
+34

No files matched your search

+7
View File
@@ -1829,7 +1829,14 @@ var CPOutlineViewIndentationPerLevelKey = @"CPOutlineViewIndentationPerLevelKey"
- (void)encodeWithCoder:(CPCoder)aCoder
{
// Make sure we don't encode our internal delegate and data source.
var internalDelegate = _delegate,
internalDataSource = _dataSource;
_delegate = nil;
_dataSource = nil;
[super encodeWithCoder:aCoder];
_delegate = internalDelegate;
_dataSource = internalDataSource;
[aCoder encodeObject:_outlineTableColumn forKey:CPOutlineViewOutlineTableColumnKey];
[aCoder encodeFloat:_indentationPerLevel forKey:CPOutlineViewIndentationPerLevelKey];
+27
View File
@@ -138,6 +138,16 @@
[self assert:1 equals:[delegate selectionChangeCount] message:"selection notifications during expandItem"];
}
/*!
Test that the outline view is properly careful about not encoding its
non-encodable delegate and data source.
*/
- (void)testCoding
{
// This should simply not crash.
var decoded = [CPKeyedUnarchiver unarchiveObjectWithData:[CPKeyedArchiver archivedDataWithRootObject:outlineView]];
}
@end
@implementation TestDataSource : CPObject
@@ -179,6 +189,23 @@
return theItem;
}
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super init];
if (self)
{
entries = [aCoder decodeObjectForKey:"entries"];
}
return self;
}
- (void)encodeWithCoder:(CPCoder)aCoder
{
[aCoder encodeObject:entries forKey:"entries"];
}
@end
@implementation TestNotificationsDelegate : CPObject