I have created a uitableviewcell using a xib. And I have a cell factory where the cell is unarchived this way:
- (instancetype)initWithNib:(NSString *)aNibName
{
self = [super init];
if (self != nil) {
self.viewTemplateStore = [[NSMutableDictionary alloc] init];
NSArray * templates = [[NSBundle mainBundle] loadNibNamed:aNibName owner:self options:nil];
for (id template in templates) {
if ([template isKindOfClass:[UITableViewCell class]]) {
UITableViewCell * cellTemplate = (UITableViewCell *)template;
NSString * key = cellTemplate.reuseIdentifier;
if (key) {
[self.viewTemplateStore setObject:[NSKeyedArchiver archivedDataWithRootObject:template] forKey:key];
} else {
@throw [NSException exceptionWithName:@"Unknown cell"
reason:@"Cell has no reuseIdentifier"
userInfo:nil];
}
}
}
}
return self;
}
- (UITableViewCell *)cellOfKind:(NSString *)theCellKind forTable:(UITableView *)aTableView
{
UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:theCellKind];
if (!cell) {
NSData * cellData = [self.viewTemplateStore objectForKey:theCellKind];
if (cellData) {
cell = [NSKeyedUnarchiver unarchiveObjectWithData:cellData];
} else {
DDLogError(@"Don't know nothing about cell of kind %@", theCellKind);
}
}
return cell;
}
If UIActivityIndicatorView is added to the cell then this message appears in the console:
* NSKeyedArchiver warning: replacing existing value for key 'UITintColor'; probable duplication of encoding keys in class hierarchy
It only happens in iOS7. The UIActivityIndicatorView has the default values, I just drag and drop it on to the cell.
Any clue about why this message appears?
Thanks.
This is a bug introduced in iOS7.
You are calling [NSKeyedArchiver archivedDataWithRootObject:template]
, which is causing the whole view hierarchy to be archived (using the procedure encodeWithCoder:
).
The problem causing the warning is that UIActivityIndicatorView
is the subclass of UIView
, which also conforms <NSCoding>
protocol. Prior to iOS7, views like Navigation Bar, Activity Indicator and others had their Tint property, but in iOS7 the Tint property is present in the UIView
itself. So both the UIViewActivityIndicator and its ancestor UIView are encoding this Tint property for UITintColor
key, first it's set by UIView
and then overwritten by UIActivityIndicatorView
. That's why this warning is appearing. No need to worry about it.
BTW, why are you using so strange code to generate cells? You may register all the reuseIdentifiers to appropriate Nib in viewDidLoad:
[self.tableView registerNib:[UINib nibWithNibName:@"Cells" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"cell1"];
and then the tableView itself will load a cell when you call
[tableView dequeueReusableCellWithIdentifier:@"cell1" forIndexPath:indexPath];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With