求助个关于NSDictionary的问题
walkingway
由 walkingway
发布于 2014年04月06日
无人欣赏。
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个数么?还是其他什么的?
共4条回复
楼长
·
nonomori
回复于 2014年04月06日
相当独特的比较方式呢。 难道你没有warning么?
2楼
·
walkingway
回复于 2014年04月06日
3楼
·
nonomori
回复于 2014年04月06日
漏写 allValues 了......
4楼
·
sojingle
回复于 2014年04月09日
应该是漏写了 .count
immutable.count == 1