Skip to content

Commit e44eab0

Browse files
authored
Merge pull request #668 from leancloud/develop
chore: tweak code
2 parents 5353ae5 + 5ff3f04 commit e44eab0

28 files changed

+90
-30
lines changed

AVOS/AVOS.xcodeproj/project.pbxproj

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
D305F7B0235577AD00222EBC /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = D305F7AF235577AD00222EBC /* main.swift */; };
1111
D30B6A1424A09978006ABE09 /* LeanCloudObjc.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D30B6A0B24A09978006ABE09 /* LeanCloudObjc.framework */; };
1212
D30B6A1B24A09978006ABE09 /* LeanCloudObjc.h in Headers */ = {isa = PBXBuildFile; fileRef = D30B6A0D24A09978006ABE09 /* LeanCloudObjc.h */; settings = {ATTRIBUTES = (Public, ); }; };
13-
D30B6A2224A09B1F006ABE09 /* UserAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 8C841AAC1A5A7A0000C5C6C4 /* UserAgent.h */; };
13+
D30B6A2224A09B1F006ABE09 /* UserAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 8C841AAC1A5A7A0000C5C6C4 /* UserAgent.h */; settings = {ATTRIBUTES = (Public, ); }; };
1414
D30B6A2424A09B1F006ABE09 /* LCGlobal.h in Headers */ = {isa = PBXBuildFile; fileRef = 8C8419F41A5A79FF00C5C6C4 /* LCGlobal.h */; };
1515
D30B6A2824A09B1F006ABE09 /* LCApplication.h in Headers */ = {isa = PBXBuildFile; fileRef = D3700B782475345C00678B2B /* LCApplication.h */; settings = {ATTRIBUTES = (Public, ); }; };
1616
D30B6A2924A09B1F006ABE09 /* LCApplication_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = D3596DAC2480EEED002D2D22 /* LCApplication_Internal.h */; };
@@ -70,7 +70,7 @@
7070
D30B6A6D24A09D62006ABE09 /* LCQuery_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 8C841A691A5A79FF00C5C6C4 /* LCQuery_Internal.h */; };
7171
D30B6A6E24A09D7B006ABE09 /* LCRequestOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 8C841A6C1A5A79FF00C5C6C4 /* LCRequestOperation.h */; };
7272
D30B6A6F24A09D7B006ABE09 /* LCRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C841A6D1A5A79FF00C5C6C4 /* LCRequestOperation.m */; };
73-
D30B6A7024A09D7B006ABE09 /* LCPaasClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 8C841A6E1A5A79FF00C5C6C4 /* LCPaasClient.h */; };
73+
D30B6A7024A09D7B006ABE09 /* LCPaasClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 8C841A6E1A5A79FF00C5C6C4 /* LCPaasClient.h */; settings = {ATTRIBUTES = (Public, ); }; };
7474
D30B6A7224A09D7B006ABE09 /* LCPaasClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C841A6F1A5A79FF00C5C6C4 /* LCPaasClient.m */; };
7575
D30B6A7324A09D87006ABE09 /* LCRouter.h in Headers */ = {isa = PBXBuildFile; fileRef = 83F9A2C51CE014430002E21B /* LCRouter.h */; };
7676
D30B6A7424A09D87006ABE09 /* LCRouter_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = D34EBDCC211C20FF0092A538 /* LCRouter_Internal.h */; };
@@ -81,19 +81,19 @@
8181
D30B6A7924A09DA3006ABE09 /* LCSearchSortBuilder.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C841A761A5A79FF00C5C6C4 /* LCSearchSortBuilder.m */; };
8282
D30B6A7C24A09DBE006ABE09 /* LCStatus.h in Headers */ = {isa = PBXBuildFile; fileRef = 8C841A781A5A7A0000C5C6C4 /* LCStatus.h */; settings = {ATTRIBUTES = (Public, ); }; };
8383
D30B6A7D24A09DBF006ABE09 /* LCStatus.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C841A791A5A7A0000C5C6C4 /* LCStatus.m */; };
84-
D30B6A7E24A09DCA006ABE09 /* LCCompatibilityMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = D37EE4AC23ACF39700AACE99 /* LCCompatibilityMacros.h */; };
85-
D30B6A7F24A09DCA006ABE09 /* LCHTTPSessionManager.h in Headers */ = {isa = PBXBuildFile; fileRef = D37EE4AD23ACF39700AACE99 /* LCHTTPSessionManager.h */; };
84+
D30B6A7E24A09DCA006ABE09 /* LCCompatibilityMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = D37EE4AC23ACF39700AACE99 /* LCCompatibilityMacros.h */; settings = {ATTRIBUTES = (Public, ); }; };
85+
D30B6A7F24A09DCA006ABE09 /* LCHTTPSessionManager.h in Headers */ = {isa = PBXBuildFile; fileRef = D37EE4AD23ACF39700AACE99 /* LCHTTPSessionManager.h */; settings = {ATTRIBUTES = (Public, ); }; };
8686
D30B6A8024A09DCA006ABE09 /* LCHTTPSessionManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D37EE4AA23ACF39700AACE99 /* LCHTTPSessionManager.m */; };
87-
D30B6A8124A09DCA006ABE09 /* LCNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = D37EE4A923ACF39700AACE99 /* LCNetworking.h */; };
88-
D30B6A8224A09DCA006ABE09 /* LCNetworkReachabilityManager.h in Headers */ = {isa = PBXBuildFile; fileRef = D37EE4AE23ACF39700AACE99 /* LCNetworkReachabilityManager.h */; };
87+
D30B6A8124A09DCA006ABE09 /* LCNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = D37EE4A923ACF39700AACE99 /* LCNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; };
88+
D30B6A8224A09DCA006ABE09 /* LCNetworkReachabilityManager.h in Headers */ = {isa = PBXBuildFile; fileRef = D37EE4AE23ACF39700AACE99 /* LCNetworkReachabilityManager.h */; settings = {ATTRIBUTES = (Public, ); }; };
8989
D30B6A8324A09DCA006ABE09 /* LCNetworkReachabilityManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D37EE4AF23ACF39700AACE99 /* LCNetworkReachabilityManager.m */; };
90-
D30B6A8424A09DCA006ABE09 /* LCSecurityPolicy.h in Headers */ = {isa = PBXBuildFile; fileRef = D37EE4B023ACF39700AACE99 /* LCSecurityPolicy.h */; };
90+
D30B6A8424A09DCA006ABE09 /* LCSecurityPolicy.h in Headers */ = {isa = PBXBuildFile; fileRef = D37EE4B023ACF39700AACE99 /* LCSecurityPolicy.h */; settings = {ATTRIBUTES = (Public, ); }; };
9191
D30B6A8524A09DCA006ABE09 /* LCSecurityPolicy.m in Sources */ = {isa = PBXBuildFile; fileRef = D37EE4A323ACF39600AACE99 /* LCSecurityPolicy.m */; };
92-
D30B6A8624A09DCA006ABE09 /* LCURLRequestSerialization.h in Headers */ = {isa = PBXBuildFile; fileRef = D37EE4A423ACF39600AACE99 /* LCURLRequestSerialization.h */; };
92+
D30B6A8624A09DCA006ABE09 /* LCURLRequestSerialization.h in Headers */ = {isa = PBXBuildFile; fileRef = D37EE4A423ACF39600AACE99 /* LCURLRequestSerialization.h */; settings = {ATTRIBUTES = (Public, ); }; };
9393
D30B6A8724A09DCA006ABE09 /* LCURLRequestSerialization.m in Sources */ = {isa = PBXBuildFile; fileRef = D37EE4A623ACF39700AACE99 /* LCURLRequestSerialization.m */; };
94-
D30B6A8824A09DCA006ABE09 /* LCURLResponseSerialization.h in Headers */ = {isa = PBXBuildFile; fileRef = D37EE4A523ACF39600AACE99 /* LCURLResponseSerialization.h */; };
94+
D30B6A8824A09DCA006ABE09 /* LCURLResponseSerialization.h in Headers */ = {isa = PBXBuildFile; fileRef = D37EE4A523ACF39600AACE99 /* LCURLResponseSerialization.h */; settings = {ATTRIBUTES = (Public, ); }; };
9595
D30B6A8924A09DCA006ABE09 /* LCURLResponseSerialization.m in Sources */ = {isa = PBXBuildFile; fileRef = D37EE4A723ACF39700AACE99 /* LCURLResponseSerialization.m */; };
96-
D30B6A8A24A09DCA006ABE09 /* LCURLSessionManager.h in Headers */ = {isa = PBXBuildFile; fileRef = D37EE4A823ACF39700AACE99 /* LCURLSessionManager.h */; };
96+
D30B6A8A24A09DCA006ABE09 /* LCURLSessionManager.h in Headers */ = {isa = PBXBuildFile; fileRef = D37EE4A823ACF39700AACE99 /* LCURLSessionManager.h */; settings = {ATTRIBUTES = (Public, ); }; };
9797
D30B6A8B24A09DCA006ABE09 /* LCURLSessionManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D37EE4AB23ACF39700AACE99 /* LCURLSessionManager.m */; };
9898
D30B6A8C24A09DD8006ABE09 /* LCKeychain.h in Headers */ = {isa = PBXBuildFile; fileRef = 836705DC1BA1C1710050E968 /* LCKeychain.h */; };
9999
D30B6A8D24A09DD8006ABE09 /* LCKeychain.m in Sources */ = {isa = PBXBuildFile; fileRef = 836705DD1BA1C1710050E968 /* LCKeychain.m */; };
@@ -288,7 +288,7 @@
288288
D30B6B5524A09FB6006ABE09 /* LCRTMConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = D3700B722475244E00678B2B /* LCRTMConnection.h */; };
289289
D30B6B5624A09FB6006ABE09 /* LCRTMConnection_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = D34C417D2483C3FD00CD2459 /* LCRTMConnection_Internal.h */; };
290290
D30B6B5724A09FB6006ABE09 /* LCRTMConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = D3700B732475244E00678B2B /* LCRTMConnection.m */; };
291-
D30B6B5824A09FB6006ABE09 /* LCRTMWebSocket.h in Headers */ = {isa = PBXBuildFile; fileRef = D3120E0823B0DA8E00A64120 /* LCRTMWebSocket.h */; };
291+
D30B6B5824A09FB6006ABE09 /* LCRTMWebSocket.h in Headers */ = {isa = PBXBuildFile; fileRef = D3120E0823B0DA8E00A64120 /* LCRTMWebSocket.h */; settings = {ATTRIBUTES = (Public, ); }; };
292292
D30B6B5924A09FB6006ABE09 /* LCRTMWebSocket.m in Sources */ = {isa = PBXBuildFile; fileRef = D3120E0923B0DA8E00A64120 /* LCRTMWebSocket.m */; };
293293
D30B6B5B24A0A03D006ABE09 /* LCLiveQuery.h in Headers */ = {isa = PBXBuildFile; fileRef = 838CE3521EC9838500B24F5B /* LCLiveQuery.h */; settings = {ATTRIBUTES = (Public, ); }; };
294294
D30B6B5C24A0A03D006ABE09 /* LCLiveQuery_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = D34FD72B2068CFE900B7C11B /* LCLiveQuery_Internal.h */; };
@@ -1013,7 +1013,6 @@
10131013
8C841A7A1A5A7A0000C5C6C4 /* Vendor */ = {
10141014
isa = PBXGroup;
10151015
children = (
1016-
83FCB9911CEDC57C007D8712 /* LCNetworking */,
10171016
836705DA1BA1C1710050E968 /* JNKeychain */,
10181017
83DF02A41AF86032000E289C /* LCDB */,
10191018
);
@@ -1286,6 +1285,24 @@
12861285
name = Frameworks;
12871286
sourceTree = "<group>";
12881287
};
1288+
D3516D1A26FB19640013BCF3 /* Vendor */ = {
1289+
isa = PBXGroup;
1290+
children = (
1291+
83FCB9911CEDC57C007D8712 /* LCNetworking */,
1292+
D3516D1B26FB19860013BCF3 /* WebSocket */,
1293+
);
1294+
path = Vendor;
1295+
sourceTree = "<group>";
1296+
};
1297+
D3516D1B26FB19860013BCF3 /* WebSocket */ = {
1298+
isa = PBXGroup;
1299+
children = (
1300+
D3120E0823B0DA8E00A64120 /* LCRTMWebSocket.h */,
1301+
D3120E0923B0DA8E00A64120 /* LCRTMWebSocket.m */,
1302+
);
1303+
path = WebSocket;
1304+
sourceTree = "<group>";
1305+
};
12891306
D365E42126C3D23900148DE8 /* Leaderboard */ = {
12901307
isa = PBXGroup;
12911308
children = (
@@ -1302,8 +1319,6 @@
13021319
D3700B722475244E00678B2B /* LCRTMConnection.h */,
13031320
D34C417D2483C3FD00CD2459 /* LCRTMConnection_Internal.h */,
13041321
D3700B732475244E00678B2B /* LCRTMConnection.m */,
1305-
D3120E0823B0DA8E00A64120 /* LCRTMWebSocket.h */,
1306-
D3120E0923B0DA8E00A64120 /* LCRTMWebSocket.m */,
13071322
);
13081323
path = Connection;
13091324
sourceTree = "<group>";
@@ -1332,6 +1347,7 @@
13321347
D3F227BC2649133900A599F5 /* Sources */ = {
13331348
isa = PBXGroup;
13341349
children = (
1350+
D3516D1A26FB19640013BCF3 /* Vendor */,
13351351
8C8419881A5A791300C5C6C4 /* Foundation */,
13361352
D3F227BD264914E400A599F5 /* Realtime */,
13371353
);

AVOS/LeanCloudObjc/Foundation.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,21 @@
88

99
#import <Foundation/Foundation.h>
1010

11-
// Application
12-
#import "LCApplication.h"
11+
// Vendor
12+
#import "LCNetworking.h"
1313

1414
// Constants
15+
#import "UserAgent.h"
1516
#import "LCLogger.h"
1617
#import "LCErrorUtils.h"
1718
#import "LCUtils.h"
1819

20+
// HTTP Client
21+
#import "LCPaasClient.h"
22+
23+
// Application
24+
#import "LCApplication.h"
25+
1926
// Object
2027
#import "LCObject.h"
2128
#import "LCObject+Subclass.h"

AVOS/LeanCloudObjc/Realtime.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111
#import "Foundation.h"
1212

13+
// Vendor
14+
#import "LCRTMWebSocket.h"
15+
1316
// Constant
1417
#import "LCIMCommon.h"
1518

AVOS/Sources/Foundation/File/LCFile.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ - (instancetype)initWithLocalPath:(NSString *)localPath
188188
});
189189

190190
NSNumber *fileSize = fileAttributes[NSFileSize];
191-
_rawJSONData[kLCFile_metaData] = fileSize ? @{ kLCFile_size : fileSize } : @{};
191+
_rawJSONData[kLCFile_metaData] = (fileSize != nil) ? @{ kLCFile_size : fileSize } : @{};
192192

193193
_ACL = ({
194194

AVOS/Sources/Foundation/LCApplication.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ NS_ASSUME_NONNULL_BEGIN
166166

167167
@property (nonatomic, readonly) NSString *identifier;
168168
@property (nonatomic, readonly) NSString *key;
169+
@property (nonatomic, readonly, nullable) NSString *serverURLString;
169170
@property (nonatomic, copy, nullable) NSString *RTMServer;
170171

171172
- (void)setWithIdentifier:(NSString *)identifier key:(NSString *)key;

AVOS/Sources/Foundation/LCApplication.m

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,25 +184,37 @@ + (instancetype)defaultApplication {
184184
return instance;
185185
}
186186

187+
- (NSString *)serverURLString {
188+
return [LCRouter serverURLString];
189+
}
190+
187191
- (void)setWithIdentifier:(NSString *)identifier key:(NSString *)key {
188192
_identifier = [identifier copy];
189193
_key = [key copy];
190194
}
191195

196+
- (NSString *)identifier {
197+
return [self identifierThrowException];
198+
}
199+
200+
- (NSString *)key {
201+
return [self keyThrowException];
202+
}
203+
192204
- (NSString *)identifierThrowException {
193-
if (!self.identifier) {
205+
if (!_identifier || _identifier.length == 0) {
194206
[NSException raise:NSInternalInconsistencyException
195207
format:@"Application identifier not found."];
196208
}
197-
return self.identifier;
209+
return _identifier;
198210
}
199211

200212
- (NSString *)keyThrowException {
201-
if (!self.key) {
213+
if (!_key || _key.length == 0) {
202214
[NSException raise:NSInternalInconsistencyException
203215
format:@"Application key not found."];
204216
}
205-
return self.key;
217+
return _key;
206218
}
207219

208220
@end

AVOS/Sources/Foundation/LCApplication_Internal.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111
@interface LCApplication ()
1212

13+
@property (nonatomic) NSString *identifier;
14+
@property (nonatomic) NSString *key;
15+
1316
- (NSString *)identifierThrowException;
1417
- (NSString *)keyThrowException;
1518

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)