Skip to content

Commit 121c23f

Browse files
committed
proper ARC modifier for NSError**
1 parent aa535b4 commit 121c23f

File tree

8 files changed

+26
-11
lines changed

8 files changed

+26
-11
lines changed

Parse/Parse/Internal/Commands/PFRESTQueryCommand.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ + (nullable NSDictionary *)findCommandParametersWithOrder:(NSString *)order
209209
return parameters;
210210
}
211211

212-
+ (nullable id)_encodeSubqueryIfNeeded:(id)object error:(NSError **)error {
212+
+ (nullable id)_encodeSubqueryIfNeeded:(id)object error:(NSError * __autoreleasing *)error {
213213
if (![object isKindOfClass:[NSDictionary class]]) {
214214
return object;
215215
}

Parse/Parse/Internal/Object/LocalIdStore/PFObjectLocalIdStore.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ + (BOOL)isLocalId:(NSString *)localId {
134134
/**
135135
* Grabs one entry in the local id map off the disk.
136136
*/
137-
- (PFObjectLocalIdStoreMapEntry *)getMapEntry:(NSString *)localId error:(NSError **) error {
137+
- (PFObjectLocalIdStoreMapEntry *)getMapEntry:(NSString *)localId error:(NSError * __autoreleasing *) error {
138138

139139
PFConsistencyError(error, [[self class] isLocalId:localId], nil, @"Tried to get invalid local id: \"%@\".", localId);
140140

@@ -167,7 +167,7 @@ - (PFObjectLocalIdStoreMapEntry *)getMapEntry:(NSString *)localId error:(NSError
167167
/**
168168
* Writes one entry to the local id map on disk.
169169
*/
170-
- (BOOL)putMapEntry:(PFObjectLocalIdStoreMapEntry *)entry forLocalId:(NSString *)localId error:(NSError **)error {
170+
- (BOOL)putMapEntry:(PFObjectLocalIdStoreMapEntry *)entry forLocalId:(NSString *)localId error:(NSError * __autoreleasing *)error {
171171
PFConsistencyError(error, [[self class] isLocalId:localId], NO, @"Tried to get invalid local id: \"%@\".", localId);
172172

173173
NSString *file = [_diskPath stringByAppendingPathComponent:localId];
@@ -178,7 +178,7 @@ - (BOOL)putMapEntry:(PFObjectLocalIdStoreMapEntry *)entry forLocalId:(NSString *
178178
/**
179179
* Removes an entry from the local id map on disk.
180180
*/
181-
- (BOOL)removeMapEntry:(NSString *)localId error:(NSError **)error {
181+
- (BOOL)removeMapEntry:(NSString *)localId error:(NSError * __autoreleasing *)error {
182182
PFConsistencyError(error, [[self class] isLocalId:localId], NO, @"Tried to get invalid local id: \"%@\".", localId);
183183

184184
NSString *file = [_diskPath stringByAppendingPathComponent:localId];

Parse/Parse/Internal/Object/OperationSet/PFOperationSet.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ - (void)mergeOperationSet:(PFOperationSet *)other {
7474

7575
- (nullable NSDictionary *)RESTDictionaryUsingObjectEncoder:(PFEncoder *)objectEncoder
7676
operationSetUUIDs:(NSArray **)operationSetUUIDs
77-
error:(NSError **)error {
77+
error:(NSError * __autoreleasing *)error {
7878
NSMutableDictionary *operationSetResult = [[NSMutableDictionary alloc] init];
7979
__block NSError *encodingError;
8080
__block BOOL wasStopped = false;

Parse/Parse/Internal/Object/State/PFObjectState.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ - (void)setServerData:(NSDictionary *)serverData {
106106
#pragma mark - Coding
107107
///--------------------------------------
108108

109-
- (NSDictionary *)dictionaryRepresentationWithObjectEncoder:(PFEncoder *)objectEncoder error:(NSError **)error {
109+
- (NSDictionary *)dictionaryRepresentationWithObjectEncoder:(PFEncoder *)objectEncoder error:(NSError * __autoreleasing *)error {
110110
NSMutableDictionary *result = [NSMutableDictionary dictionary];
111111
if (self.objectId) {
112112
result[PFObjectObjectIdRESTKey] = self.objectId;

Parse/Parse/Internal/PFAssert.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ do { \
6262
Sets a recoverable error for propagation
6363
*/
6464
#define PFConsistencyError(error, condition, rval, description, ...) \
65-
if (!(condition) && error) { \
66-
*error = [PFErrorUtilities errorWithCode:-1 message:[NSString stringWithFormat:description, ##__VA_ARGS__]];\
65+
if (!(condition) && error && *error == nil) { \
66+
*error = [PFErrorUtilities errorWithCode:-1 message:[NSString stringWithFormat:description, ##__VA_ARGS__]];\
6767
return rval;\
6868
}
6969

Parse/Parse/PFEncoder.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ + (instancetype)objectEncoder {
3333
return encoder;
3434
}
3535

36-
- (id)encodeObject:(id)object error:(NSError **) error {
36+
- (id)encodeObject:(id)object error:(NSError * __autoreleasing *) error {
3737
if ([object isKindOfClass:[PFObject class]]) {
3838
return [self encodeParseObject:object error:error];
3939
} else if ([object isKindOfClass:[NSData class]]) {
@@ -190,7 +190,7 @@ + (instancetype)objectEncoder {
190190
return encoder;
191191
}
192192

193-
- (id)encodeParseObject:(PFObject *)object error:(NSError **)error {
193+
- (id)encodeParseObject:(PFObject *)object error:(NSError * __autoreleasing *)error {
194194
PFConsistencyError(error, object.objectId, nil, @"Tried to save an object with a new, unsaved child.");
195195
return [super encodeParseObject:object error:error];
196196
}

Parse/Parse/PFObject.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ - (NSString *)getOrCreateLocalId {
745745
return self.localId;
746746
}
747747

748-
- (BOOL)resolveLocalId:(NSError **)error {
748+
- (BOOL)resolveLocalId:(NSError *__autoreleasing*)error {
749749
@synchronized (lock) {
750750
PFConsistencyAssert(self.localId, @"Tried to resolve a localId for an object with no localId.");
751751
NSString *newObjectId = [[Parse _currentManager].coreManager.objectLocalIdStore objectIdForLocalId:self.localId];

Parse/Tests/Unit/ObjectLocalIdStoreTests.m

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,19 @@ - (void)testLongSerialization {
140140
XCTAssertEqual(expected, actual, @"The number should be parsed correctly.");
141141
}
142142

143+
- (void)testInvalidLocalId {
144+
id<PFFileManagerProvider> dataSource = [self mockedDataSource];
145+
PFFileManager *fileManager = dataSource.fileManager;
146+
OCMStub([fileManager parseDataItemPathForPathComponent:[OCMArg isNotNil]]).andReturn(NSTemporaryDirectory());
147+
148+
PFObjectLocalIdStore *store = [[PFObjectLocalIdStore alloc] initWithDataSource:dataSource];
149+
NSError *error;
150+
BOOL rval = [store retainLocalIdOnDisk:@"bad-local-id" error:&error];
151+
XCTAssertFalse(rval);
152+
XCTAssertNotNil(error.domain);
153+
XCTAssertEqual(error.domain, PFParseErrorDomain);
154+
XCTAssertEqual(error.code, -1);
155+
XCTAssertEqualObjects(error.localizedDescription, @"Tried to get invalid local id: \"bad-local-id\".");
156+
}
157+
143158
@end

0 commit comments

Comments
 (0)