主帖
4 条回复
求助个关于NSDictionary的问题
id sharedKeySet = [NSDictionary sharedKeySetForKeys:@[@1, @2, @3]];
NSMutableDictionary *test = [NSMutableDictionary dictionaryWithSharedKeySet:sharedKeySet];
test[@4] = @"First element (not in the shared key set, but will work as well)";
NSDictionary *immutable = [test copy];
NSParameterAssert(immutable == 1);
((NSMutableDictionary *)immutable)[@5] = @"Adding objects to an immutable collection should throw an exception.";
NSParameterAssert(immutable == 2);
上面代码断言那里直接用一个字典对象和1进行比较,immutable == 1 这种用法是判断immutable里的value个数么?还是其他什么的?