Fix 10.7 compatibility and add a window to show an exception log
This commit is contained in:
1 parent
60b1c60155
commit
d1360727ec
13 files changed
+452
No files matched your search
+50
@@ -0,0 +1,50 @@
|
||||
//
|
||||
// NSMutableArray+Subscript.m
|
||||
//
|
||||
//
|
||||
// Created by Sernin van de Krol on 8/21/12.
|
||||
// Copyright (c) 2012 Sernin van de Krol. All rights reserved.
|
||||
//
|
||||
#if __has_feature(objc_arc)
|
||||
|
||||
#import "NSMutableArray+Subscript.h"
|
||||
|
||||
@implementation NSMutableArray (Subscript)
|
||||
|
||||
+ (void)load
|
||||
{
|
||||
Class class = [self class];
|
||||
|
||||
SEL swizzledSelector = @selector(dg_setObject:atIndexedSubscript:);
|
||||
Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);
|
||||
|
||||
class_addMethod([NSMutableArray class],
|
||||
@selector(setObject:atIndexedSubscript:),
|
||||
method_getImplementation(swizzledMethod),
|
||||
method_getTypeEncoding(swizzledMethod)
|
||||
);
|
||||
}
|
||||
|
||||
- (void)dg_setObject:(id)anObject atIndexedSubscript:(NSUInteger)index
|
||||
{
|
||||
if(anObject == nil)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException format:@"setObject:atIndexedSubscript does not allow objects to be nil"];
|
||||
}
|
||||
if(index > self.count)
|
||||
{
|
||||
[NSException raise:NSRangeException format:@"setObject:atIndexedSubscript does not allow the index to be out of array bounds"];
|
||||
}
|
||||
if(index == self.count)
|
||||
{
|
||||
[self addObject:anObject];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self replaceObjectAtIndex:index withObject:anObject];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user