Skip to content

Commit 22e7788

Browse files
authored
Merge pull request #666 from zapcannon87/develop
chore: tweak code
2 parents 881b206 + 06b3d6e commit 22e7788

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

AVOS/Sources/Foundation/Query/LCQuery.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,18 @@ NS_ASSUME_NONNULL_BEGIN
109109
*/
110110
- (void)includeKey:(NSString *)key;
111111

112+
/// Reset included keys.
113+
- (void)resetIncludeKey;
114+
112115
/*!
113116
Make the query restrict the fields of the returned LCObjects to include only the provided keys.
114117
If this is called multiple times, then all of the keys specified in each of the calls will be included.
115118
@param keys The keys to include in the result.
116119
*/
117-
- (void)selectKeys:(NSArray *)keys;
120+
- (void)selectKeys:(NSArray<NSString *> *)keys;
121+
122+
/// Reset selected keys.
123+
- (void)resetSelectKey;
118124

119125
/*!
120126
Add a constraint that requires a particular key exists.

AVOS/Sources/Foundation/Query/LCQuery.m

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,19 +171,25 @@ - (void)doInitialization {
171171
_maxCacheAge = 24 * 3600;
172172
}
173173

174-
- (void)includeKey:(NSString *)key
175-
{
174+
- (void)includeKey:(NSString *)key {
176175
[self.include addObject:key];
177176
}
178177

179-
- (void)selectKeys:(NSArray *)keys
180-
{
181-
if (self.selectedKeys == nil) {
182-
_selectedKeys = [[NSMutableSet alloc] initWithCapacity:keys.count];
178+
- (void)resetIncludeKey {
179+
self.include = [[NSMutableSet alloc] init];
180+
}
181+
182+
- (void)selectKeys:(NSArray<NSString *> *)keys {
183+
if (!self.selectedKeys) {
184+
self.selectedKeys = [[NSMutableSet alloc] initWithCapacity:keys.count];
183185
}
184186
[self.selectedKeys addObjectsFromArray:keys];
185187
}
186188

189+
- (void)resetSelectKey {
190+
self.selectedKeys = nil;
191+
}
192+
187193
- (void)addWhereItem:(id)dict forKey:(NSString *)key {
188194
if ([dict objectForKey:@"$eq"]) {
189195
if ([self.where objectForKey:@"$and"]) {

AVOS/Sources/Foundation/Query/LCQuery_Internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
@interface LCQuery ()
1212
@property (nonatomic, readwrite, strong) NSMutableDictionary *parameters;
1313
@property (nonatomic, readwrite, strong) NSMutableDictionary *where;
14-
@property (nonatomic, readwrite, strong) NSMutableSet * selectedKeys;
14+
@property (nonatomic) NSMutableSet<NSString *> *selectedKeys;
1515
@property (nonatomic, strong) NSMutableDictionary *extraParameters;
1616

1717
- (NSDictionary *)assembleParameters;

0 commit comments

Comments
 (0)