Skip to content

Commit 5d92277

Browse files
committed
Merge pull request #552 from ParsePlatform/nlutsneko.modern.literal
Use ObjC literals for Dictionaries/Arrays.
2 parents 46da51b + f51b986 commit 5d92277

File tree

16 files changed

+56
-56
lines changed

16 files changed

+56
-56
lines changed

Parse/Internal/ACL/State/PFACLState.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ - (instancetype)init {
3232
self = [super init];
3333
if (!self) return nil;
3434

35-
_permissions = [NSDictionary dictionary];
35+
_permissions = @{};
3636
_shared = NO;
3737

3838
return self;

Parse/Internal/Analytics/Utilities/PFAnalyticsUtilities.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ + (NSString *)md5DigestFromPushPayload:(id)payload {
2424
[components addObject:key];
2525

2626
// alert[@"loc-args"] can be an NSArray
27-
id value = [dict objectForKey:key];
27+
id value = dict[key];
2828
if ([value isKindOfClass:[NSArray class]]) {
2929
value = [value componentsJoinedByString:@""];
3030
}

Parse/Internal/Commands/PFRESTQueryCommand.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ + (NSDictionary *)findCommandParametersWithOrder:(NSString *)order
157157
if ([queryDict count] > 0) {
158158
[newArray addObject:queryDict];
159159
} else {
160-
[newArray addObject:[NSDictionary dictionary]];
160+
[newArray addObject:@{}];
161161
}
162162
}
163163
whereData[key] = newArray;

Parse/Internal/FieldOperation/PFFieldOperation.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ + (instancetype)addRelationToObjects:(NSArray *)targets {
420420
+ (instancetype)removeRelationToObjects:(NSArray *)targets {
421421
PFRelationOperation *operation = [[self alloc] init];
422422
if (targets.count > 0) {
423-
operation.targetClass = [[targets objectAtIndex:0] parseClassName];
423+
operation.targetClass = [targets[0] parseClassName];
424424
}
425425

426426
for (PFObject *target in targets) {

Parse/Internal/LocalDataStore/OfflineStore/PFOfflineStore.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ - (BFTask *)fetchObjectLocallyAsync:(PFObject *)object database:(PFSQLiteDatabas
181181
NSString *query = [NSString stringWithFormat:@"SELECT %@ FROM %@ WHERE %@ = ?;",
182182
PFOfflineStoreKeyOfJSON, PFOfflineStoreTableOfObjects, PFOfflineStoreKeyOfUUID];
183183
return [database executeQueryAsync:query
184-
withArgumentsInArray:[NSArray arrayWithObjects:uuid, nil]];
184+
withArgumentsInArray:@[ uuid ]];
185185
}] continueWithSuccessBlock:^id(BFTask *task) {
186186
PFSQLiteDatabaseResult *result = task.result;
187187
if (![result next]) {

Parse/Internal/Object/LocalIdStore/PFObjectLocalIdStore.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ - (PFObjectLocalIdStoreMapEntry *)getMapEntry:(NSString *)localId {
154154
// If there's an objectId in memory, make sure it matches the one in the
155155
// file. This is in case the id was retained on disk *after* it was resolved.
156156
if (!entry.objectId) {
157-
NSString *objectId = [_inMemoryCache objectForKey:localId];
157+
NSString *objectId = _inMemoryCache[localId];
158158
if (objectId) {
159159
entry.objectId = objectId;
160160
if (entry.referenceCount > 0) {
@@ -250,7 +250,7 @@ - (void)setObjectId:(NSString *)objectId forLocalId:(NSString *)localId {
250250
*/
251251
- (NSString *)objectIdForLocalId:(NSString *)localId {
252252
@synchronized (_lock) {
253-
NSString *objectId = [_inMemoryCache objectForKey:localId];
253+
NSString *objectId = _inMemoryCache[localId];
254254
if (objectId) {
255255
return objectId;
256256
}

Parse/Internal/PFErrorUtilities.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ + (NSError *)errorFromResult:(NSDictionary *)result {
2929
}
3030

3131
+ (NSError *)errorFromResult:(NSDictionary *)result shouldLog:(BOOL)shouldLog {
32-
NSInteger errorCode = [[result objectForKey:@"code"] integerValue];
32+
NSInteger errorCode = [result[@"code"] integerValue];
3333

34-
NSString *errorExplanation = [result objectForKey:@"error"];
34+
NSString *errorExplanation = result[@"error"];
3535

3636
if (shouldLog) {
3737
PFLogError(PFLoggingTagCommon,

Parse/Internal/PFInternalUtils.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ + (void)appendDictionary:(NSDictionary *)dictionary toString:(NSMutableString *)
168168
for (NSString *key in keys) {
169169
[string appendFormat:@"%@:", key];
170170

171-
id value = [dictionary objectForKey:key];
171+
id value = dictionary[key];
172172
[self appendObject:value toString:string];
173173

174174
[string appendString:@","];

Parse/Internal/Purchase/PaymentTransactionObserver/PFPaymentTransactionObserver.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ - (void)completeTransaction:(SKPaymentTransaction *)transaction fromPaymentQueue
6868
}
6969

7070
@synchronized(runOnceLockObj) {
71-
void(^runOnceBlock)(NSError *) = (void(^)(NSError *))[self.runOnceBlocks objectForKey:productIdentifier];
71+
void(^runOnceBlock)(NSError *) = (void(^)(NSError *))self.runOnceBlocks[productIdentifier];
7272
if (runOnceBlock) {
7373
runOnceBlock(transaction.error);
7474
[self.runOnceBlocks removeObjectForKey:productIdentifier];

Parse/Internal/Query/Utilities/PFQueryUtilities.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ + (NSPredicate *)_negatePredicate:(NSPredicate *)predicate {
6868
compoundBlock:^NSPredicate *(NSCompoundPredicate *compound) {
6969
switch (compound.compoundPredicateType) {
7070
case NSNotPredicateType: {
71-
return [compound.subpredicates objectAtIndex:0];
71+
return compound.subpredicates[0];
7272
}
7373
case NSAndPredicateType: {
7474
NSMutableArray *newSubpredicates =
@@ -176,7 +176,7 @@ + (NSPredicate *)removeNegation:(NSPredicate *)predicate {
176176
// If this is a NOT predicate, return the negation of the subpredicate.
177177
// Otherwise, just pass it on.
178178
if (compound.compoundPredicateType == NSNotPredicateType) {
179-
return [self _negatePredicate:[newSubpredicates objectAtIndex:0]];
179+
return [self _negatePredicate:newSubpredicates[0]];
180180
} else {
181181
return [[NSCompoundPredicate alloc] initWithType:compound.compoundPredicateType
182182
subpredicates:newSubpredicates];

0 commit comments

Comments
 (0)