@@ -23,7 +23,7 @@ @implementation JSONModelArray
23
23
Class _targetClass;
24
24
}
25
25
26
- - (id )initWithArray : (NSArray *)array modelClass : (Class )cls
26
+ -(id )initWithArray : (NSArray *)array modelClass : (Class )cls
27
27
{
28
28
self = [super init ];
29
29
@@ -34,22 +34,22 @@ - (id)initWithArray:(NSArray *)array modelClass:(Class)cls
34
34
return self;
35
35
}
36
36
37
- - (id )firstObject
37
+ -(id )firstObject
38
38
{
39
39
return [self objectAtIndex: 0 ];
40
40
}
41
41
42
- - (id )lastObject
42
+ -(id )lastObject
43
43
{
44
44
return [self objectAtIndex: _storage.count - 1 ];
45
45
}
46
46
47
- - (id )objectAtIndex : (NSUInteger )index
47
+ -(id )objectAtIndex : (NSUInteger )index
48
48
{
49
49
return [self objectAtIndexedSubscript: index];
50
50
}
51
51
52
- - (id )objectAtIndexedSubscript : (NSUInteger )index
52
+ -(id )objectAtIndexedSubscript : (NSUInteger )index
53
53
{
54
54
id object = _storage[index];
55
55
if (![object isMemberOfClass: _targetClass]) {
@@ -62,22 +62,22 @@ - (id)objectAtIndexedSubscript:(NSUInteger)index
62
62
return object;
63
63
}
64
64
65
- - (void )forwardInvocation : (NSInvocation *)anInvocation
65
+ -(void )forwardInvocation : (NSInvocation *)anInvocation
66
66
{
67
67
[anInvocation invokeWithTarget: _storage];
68
68
}
69
69
70
70
-(id )forwardingTargetForSelector : (SEL )selector
71
71
{
72
72
static NSArray * overridenMethods = nil ;
73
- if (!overridenMethods) overridenMethods = @[@" initWithArray:modelClass:" ,@" objectAtIndex:" ,@" objectAtIndexedSubscript:" , @" count" ,@" modelWithIndexValue:" ,@" description" ,@" mutableCopy" ,@" firstObject" ,@" lastObject" ];
73
+ if (!overridenMethods) overridenMethods = @[@" initWithArray:modelClass:" ,@" objectAtIndex:" ,@" objectAtIndexedSubscript:" , @" count" ,@" modelWithIndexValue:" ,@" description" ,@" mutableCopy" ,@" firstObject" ,@" lastObject" , @" countByEnumeratingWithState:objects:count: " ];
74
74
if ([overridenMethods containsObject: NSStringFromSelector (selector)]) {
75
75
return self;
76
76
}
77
77
return _storage;
78
78
}
79
79
80
- - (NSUInteger )count
80
+ -(NSUInteger )count
81
81
{
82
82
return _storage.count ;
83
83
}
@@ -114,4 +114,32 @@ -(NSString*)description
114
114
return res;
115
115
}
116
116
117
+ -(NSUInteger )countByEnumeratingWithState : (NSFastEnumerationState *)state
118
+ objects : (id __unsafe_unretained [])stackbuf
119
+ count : (NSUInteger )stackbufLength
120
+ {
121
+ NSUInteger count = 0 ;
122
+
123
+ unsigned long countOfItemsAlreadyEnumerated = state->state ;
124
+
125
+ if (countOfItemsAlreadyEnumerated == 0 ) {
126
+ state->mutationsPtr = &state->extra [0 ];
127
+ }
128
+
129
+ if (countOfItemsAlreadyEnumerated < [self count ]) {
130
+ state->itemsPtr = stackbuf;
131
+ while ((countOfItemsAlreadyEnumerated < [self count ]) && (count < stackbufLength)) {
132
+ stackbuf[count] = [self objectAtIndex: countOfItemsAlreadyEnumerated];
133
+ countOfItemsAlreadyEnumerated++;
134
+ count++;
135
+ }
136
+ } else {
137
+ count = 0 ;
138
+ }
139
+
140
+ state->state = countOfItemsAlreadyEnumerated;
141
+
142
+ return count;
143
+ }
144
+
117
145
@end
0 commit comments