mirror of
https://github.com/darlinghq/darling-corefoundation.git
synced 2024-12-03 17:30:48 +00:00
Add exceptions to "initWithObjects: count:"
This commit is contained in:
parent
f72a5756b6
commit
3051ba07b1
14
NSSet.m
14
NSSet.m
@ -269,6 +269,20 @@ SINGLETON_RR()
|
||||
|
||||
- (id)initWithObjects:(const id [])objects count:(NSUInteger)cnt
|
||||
{
|
||||
if (objects == nil && cnt != 0) {
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:(NSString *)CFSTR("The object array is nil while the count is not zero")];
|
||||
}
|
||||
|
||||
// This probably isn't the most efficent way to error check, but I can't think of a better way to implement this.
|
||||
for (int i = 0; i < cnt; i++) {
|
||||
id value = objects[i];
|
||||
if (value == nil) {
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:[(NSString *)CFStringCreateWithFormat(NULL,NULL,CFSTR("The object at objects[%d] is nil."),i) autorelease]];
|
||||
}
|
||||
}
|
||||
|
||||
if (self == mutablePlaceholder)
|
||||
{
|
||||
CFMutableSetRef set = CFSetCreateMutable(kCFAllocatorDefault, cnt, &sNSCFSetCallBacks);
|
||||
|
Loading…
Reference in New Issue
Block a user