Ensuring all instance variables initialized to same values as initWithFrame: on coder init

Signed-off-by: Francisco Ryan Tolmasky I <francisco@280north.com>
This commit is contained in:
Marc Nijdam authored and Francisco Ryan Tolmasky I committed 2009-07-18 03:03:14 +08:00
1 parent 215619e6e2
commit 9c226ae574
2 files changed
+23 -7

No files matched your search

+8 -6
View File
@@ -736,13 +736,16 @@ var CPCollectionViewMinItemSizeKey = @"CPCollectionViewMinItemSizeKey",
_itemSize = CGSizeMakeZero();
_minItemSize = [aCoder decodeSizeForKey:CPCollectionViewMinItemSizeKey];
_maxItemSize = [aCoder decodeSizeForKey:CPCollectionViewMaxItemSizeKey];
_minItemSize = [aCoder decodeSizeForKey:CPCollectionViewMinItemSizeKey] || CGSizeMakeZero();
_maxItemSize = [aCoder decodeSizeForKey:CPCollectionViewMaxItemSizeKey] || CGSizeMakeZero();
_verticalMargin = [aCoder decodeFloatForKey:CPCollectionViewVerticalMarginKey];
_tileWidth = -1.0;
_selectionIndexes = [CPIndexSet indexSet];
_allowsEmptySelection = YES;
_isSelectable = YES;
}
return self;
@@ -752,14 +755,13 @@ var CPCollectionViewMinItemSizeKey = @"CPCollectionViewMinItemSizeKey",
{
[super encodeWithCoder:aCoder];
if (_minItemSize != nil)
if (!CGSizeEqualToSize(_minItemSize, CGSizeMakeZero()))
[aCoder encodeSize:_minItemSize forKey:CPCollectionViewMinItemSizeKey];
if (_maxItemSize != nil)
if (!CGSizeEqualToSize(_maxItemSize, CGSizeMakeZero()))
[aCoder encodeSize:_maxItemSize forKey:CPCollectionViewMaxItemSizeKey];
if (_verticalMargin != nil)
[aCoder encodeFloat:_verticalMargin forKey:CPCollectionViewVerticalMarginKey];
[aCoder encodeFloat:_verticalMargin forKey:CPCollectionViewVerticalMarginKey];
}
@end
+15 -1
View File
@@ -26,6 +26,21 @@
- (id)NS_initWithCoder:(CPCoder)aCoder
{
_items = [];
_content = [];
_cachedItems = [];
_itemSize = CGSizeMakeZero();
_minItemSize = CGSizeMakeZero();
_maxItemSize = CGSizeMakeZero();
_verticalMargin = 5.0;
_tileWidth = -1.0;
_selectionIndexes = [CPIndexSet indexSet];
_allowsEmptySelection = YES;
if (self = [super NS_initWithCoder:aCoder])
{
_maxNumberOfRows = [aCoder decodeIntForKey:@"NSMaxNumberOfGridRows"];
@@ -33,7 +48,6 @@
_isSelectable = [aCoder decodeBoolForKey:@"NSSelectable"];
_allowsMultipleSelection = [aCoder decodeBoolForKey:@"NSAllowsMultipleSelection"];
}
return self;