下面是我的代码,请帮我查一下这个错误的原因是什么。 错误是
xxx_objectAtIndex :( NSUInteger)索引无法正常工作
代码:
+ (void)load
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
Class class = [self class];
/* When swizzling a class method, use the following: */
/* Class class = object_getClass((id)self); */
SEL originalSelector = @selector(objectAtIndex:);/* NSArray's way */
SEL swizzledSelector = @selector(xxx_objectAtIndex:);/* will change way */
Method originalMethod = class_getInstanceMethod(class, originalSelector);
Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);
method_exchangeImplementations(originalMethod, swizzledMethod);
});
}
/*but when I use objectAtIndex: not perform this way*/
- (id)xxx_objectAtIndex:(NSUInteger)index
{
NSLog(@"=========1===========");
if (index < self.count)
{
return [self xxx_objectAtIndex:index];
}
return @"";
}