mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-25 04:57:03 +00:00
Fixed: instantiating a cib with no owner would generate nil warning
Previously, when a view-based table: - Had no delegate. - Used bindings for its data source, thus obviating the need for makeViewWithIdentifier:owner:. it would eventually call CPCib -instantiateCibWithOwner:topLevelObjects: with a nil owner (the nil table delegate). This method would try to construct a dictionary with the nil owner, which would generate a deprecation warning, and will in the future fail altogether. In Cocoa, this is exactly what happens, the owner is nil. And the documentation for -instantiateNibWithOwner:topLevelObjects: clearly states that the owner may be nil. This commit only adds the owner to the name table dictionary if the owner is non-nil. Since objectForKey: with a non-existent key returns nil, this is the same as storing nil for that key.
This commit is contained in:
+8
-1
@@ -165,7 +165,14 @@ var CPCibObjectDataKey = @"CPCibObjectDataKey";
|
||||
|
||||
- (BOOL)instantiateCibWithOwner:(id)anOwner topLevelObjects:(CPArray)topLevelObjects
|
||||
{
|
||||
return [self instantiateCibWithExternalNameTable:@{ CPCibOwner: anOwner, CPCibTopLevelObjects: topLevelObjects }];
|
||||
// anOwner can be nil, and we can't store nil in a dictionary. If we leave it out,
|
||||
// anyone who asks for CPCibOwner will get nil back.
|
||||
var nameTable = @{ CPCibTopLevelObjects: topLevelObjects };
|
||||
|
||||
if (anOwner)
|
||||
[nameTable setObject:anOwner forKey:CPCibOwner];
|
||||
|
||||
return [self instantiateCibWithExternalNameTable:nameTable];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user