详细视图开发全解析
1. 为 NSArray 添加新方法
首先,我们要为 NSArray 类添加两个新方法, nestedObjectAtIndexPath: 和 countOfNestedArray: 。操作步骤如下:
1. 单点击 NSArray - NestedArrays.m 文件,并将其内容替换为以下代码:
#import "NSArray-NestedArrays.h"
@implementation NSArray(NestedArrays)
- (id)nestedObjectAtIndexPath:(NSIndexPath *)indexPath {
NSUInteger row = [indexPath row];
NSUInteger section = [indexPath section];
NSArray *subArray = [self objectAtIndex:section];
if (![subArray isKindOfClass:[NSArray class]])
return nil;
if (row >= [subArray count])
return nil;
return [subArray objectAtIndex:row];
}
- (NSInteger)countOfNestedArray:(NSUInteger)section {
超级会员免费看
订阅专栏 解锁全文
1830

被折叠的 条评论
为什么被折叠?



