@@ -17,10 +17,12 @@ #import "NSDictionary_OFDictionary.h" #import "OFDictionary.h" #import "NSBridging.h" #import "OFBridging.h" + +#import "OFOutOfRangeException.h" @implementation NSDictionary_OFDictionary - initWithOFDictionary: (OFDictionary*)dictionary_ { if ((self = [super init]) != nil) { @@ -47,10 +49,15 @@ return [object NSObject]; return object; } -- (size_t)count +- (NSUInteger)count { - return [dictionary count]; + size_t count = [dictionary count]; + + if (count > NSUIntegerMax) + @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + + return (NSUInteger)count; } @end