commit | author | age
|
3eceb5
|
1 |
// |
W |
2 |
// VKApiObjectArray.h |
|
3 |
// |
|
4 |
// Copyright (c) 2014 VK.com |
|
5 |
// |
|
6 |
// Permission is hereby granted, free of charge, to any person obtaining a copy of |
|
7 |
// this software and associated documentation files (the "Software"), to deal in |
|
8 |
// the Software without restriction, including without limitation the rights to |
|
9 |
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of |
|
10 |
// the Software, and to permit persons to whom the Software is furnished to do so, |
|
11 |
// subject to the following conditions: |
|
12 |
// |
|
13 |
// The above copyright notice and this permission notice shall be included in all |
|
14 |
// copies or suabstantial portions of the Software. |
|
15 |
// |
|
16 |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
17 |
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
|
18 |
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
|
19 |
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
|
20 |
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
|
21 |
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
22 |
|
|
23 |
#import "VKApiObject.h" |
|
24 |
|
|
25 |
/** |
|
26 |
Base class for VK API arrays |
|
27 |
*/ |
|
28 |
@interface VKApiObjectArray<__covariant ApiObjectType : VKApiObject*> : VKApiObject <NSFastEnumeration> |
|
29 |
/// Count of items in array |
|
30 |
@property(nonatomic, readonly) NSUInteger count; |
|
31 |
/// Parsed array items |
|
32 |
@property(nonatomic, strong) NSMutableArray<ApiObjectType> *items; |
|
33 |
|
|
34 |
/** |
|
35 |
Initialize object with API json dictionary. This method tries to set all known properties of current class from dictionary |
|
36 |
@param dict API json dictionary |
|
37 |
@param objectClass class of items inside of array |
|
38 |
@return Initialized object |
|
39 |
*/ |
|
40 |
- (instancetype)initWithDictionary:(NSDictionary *)dict objectClass:(Class)objectClass; |
|
41 |
|
|
42 |
/** |
|
43 |
Initialize object with API json array. This method tries to set all known properties of current class from array |
|
44 |
@param array API json array |
|
45 |
@param objectClass class of items inside of array |
|
46 |
@return Initialized object |
|
47 |
*/ |
|
48 |
- (instancetype)initWithArray:(NSArray *)array objectClass:(Class)objectClass; |
|
49 |
|
|
50 |
/** |
|
51 |
Initialize object with any array. items property is sets as passed array, count is a count of items in passed array |
|
52 |
@param array API json array |
|
53 |
@return Initialized object |
|
54 |
*/ |
|
55 |
- (instancetype)initWithArray:(NSArray *)array; |
|
56 |
|
|
57 |
/// Array funtions |
|
58 |
|
|
59 |
- (ApiObjectType)objectAtIndex:(NSInteger)idx; |
|
60 |
|
|
61 |
- (ApiObjectType)objectAtIndexedSubscript:(NSUInteger)idx NS_AVAILABLE(10_8, 6_0); |
|
62 |
|
|
63 |
- (NSEnumerator *)objectEnumerator; |
|
64 |
|
|
65 |
- (NSEnumerator *)reverseObjectEnumerator; |
|
66 |
|
|
67 |
- (void)addObject:(ApiObjectType)object; |
|
68 |
|
|
69 |
- (void)removeObject:(ApiObjectType)object; |
|
70 |
|
|
71 |
- (void)insertObject:(ApiObjectType)object atIndex:(NSUInteger)index; |
|
72 |
|
|
73 |
- (ApiObjectType)firstObject; |
|
74 |
|
|
75 |
- (ApiObjectType)lastObject; |
|
76 |
|
|
77 |
- (void)serializeTo:(NSMutableDictionary *)dict withName:(NSString *)name; |
|
78 |
|
|
79 |
- (Class)objectClass; |
|
80 |
@end |