@@ -23,7 +23,7 @@ @implementation JSONModelArray
2323 Class _targetClass;
2424}
2525
26- - (id )initWithArray : (NSArray *)array modelClass : (Class )cls
26+ -(id )initWithArray : (NSArray *)array modelClass : (Class )cls
2727{
2828 self = [super init ];
2929
@@ -34,22 +34,22 @@ - (id)initWithArray:(NSArray *)array modelClass:(Class)cls
3434 return self;
3535}
3636
37- - (id )firstObject
37+ -(id )firstObject
3838{
3939 return [self objectAtIndex: 0 ];
4040}
4141
42- - (id )lastObject
42+ -(id )lastObject
4343{
4444 return [self objectAtIndex: _storage.count - 1 ];
4545}
4646
47- - (id )objectAtIndex : (NSUInteger )index
47+ -(id )objectAtIndex : (NSUInteger )index
4848{
4949 return [self objectAtIndexedSubscript: index];
5050}
5151
52- - (id )objectAtIndexedSubscript : (NSUInteger )index
52+ -(id )objectAtIndexedSubscript : (NSUInteger )index
5353{
5454 id object = _storage[index];
5555 if (![object isMemberOfClass: _targetClass]) {
@@ -62,22 +62,22 @@ - (id)objectAtIndexedSubscript:(NSUInteger)index
6262 return object;
6363}
6464
65- - (void )forwardInvocation : (NSInvocation *)anInvocation
65+ -(void )forwardInvocation : (NSInvocation *)anInvocation
6666{
6767 [anInvocation invokeWithTarget: _storage];
6868}
6969
7070-(id )forwardingTargetForSelector : (SEL )selector
7171{
7272 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: " ];
7474 if ([overridenMethods containsObject: NSStringFromSelector (selector)]) {
7575 return self;
7676 }
7777 return _storage;
7878}
7979
80- - (NSUInteger )count
80+ -(NSUInteger )count
8181{
8282 return _storage.count ;
8383}
@@ -114,4 +114,32 @@ -(NSString*)description
114114 return res;
115115}
116116
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+
117145@end
0 commit comments