hook NSArray 方法在debug模式下会崩溃, 在release模式下会返回nil

246 阅读1分钟

配合hook的使用 防崩溃

- (id)hook_objectAtIndex:(NSUInteger)index

{

    if (index < self.count) {

        return [self hook_objectAtIndex:index];

    } else {

#ifdef DEBUG

        AC_Assert(NO);

        NSAssert2(YES, @"aaaaa%d , count %d", index, 2);

#endif

        return nil;

    }

}