Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Parse.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8597,13 +8597,15 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 81DCD1491D2DA080002501A2 /* Debug.xcconfig */;
buildSettings = {
SWIFT_VERSION = 3.0;
};
name = Debug;
};
09D3366C139C54940098E916 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 81DCD14A1D2DA080002501A2 /* Release.xcconfig */;
buildSettings = {
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand Down
2 changes: 1 addition & 1 deletion Parse/Internal/ACL/State/PFACLState.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ typedef void (^PFACLStateMutationBlock)(PFMutableACLState *);

@interface PFACLState : PFBaseState<PFBaseStateSubclass, NSCopying, NSMutableCopying>

@property (nonatomic, copy, readonly) NSDictionary<NSString *, id> *permissions;
@property (nonatomic, strong, readonly) NSDictionary<NSString *, id> *permissions;
@property (nonatomic, assign, readonly, getter=isShared) BOOL shared;

///--------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion Parse/Internal/ACL/State/PFACLState_Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
BOOL _shared;
}

@property (nonatomic, copy, readwrite) NSDictionary<NSString *, id> *permissions;
@property (nonatomic, strong, readwrite) NSDictionary<NSString *, id> *permissions;
@property (nonatomic, assign, readwrite, getter=isShared) BOOL shared;

@end
2 changes: 1 addition & 1 deletion Parse/Internal/ACL/State/PFMutableACLState.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ NS_ASSUME_NONNULL_BEGIN

@interface PFMutableACLState : PFACLState

@property (nonatomic, copy, readwrite) NSMutableDictionary<NSString *, id> *permissions;
@property (nonatomic, strong, readwrite) NSMutableDictionary<NSString *, id> *permissions;
@property (nonatomic, assign, readwrite, getter=isShared) BOOL shared;

@end
Expand Down
2 changes: 1 addition & 1 deletion Parse/Internal/KeyValueCache/PFKeyValueCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Getting
///--------------------------------------

- (NSString *)objectForKey:(NSString *)key maxAge:(NSTimeInterval)age;
- (nullable NSString *)objectForKey:(NSString *)key maxAge:(NSTimeInterval)age;

///--------------------------------------
#pragma mark - Removing
Expand Down
2 changes: 1 addition & 1 deletion Parse/Internal/KeyValueCache/PFKeyValueCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ - (void)setObject:(NSString *)value forKey:(NSString *)key {
});
}

- (NSString *)objectForKey:(NSString *)key maxAge:(NSTimeInterval)maxAge {
- (nullable NSString *)objectForKey:(NSString *)key maxAge:(NSTimeInterval)maxAge {
NSURL *cacheURL = [self _cacheURLForKey:key];
PFKeyValueCacheEntry *cacheEntry = [self.memoryCache objectForKey:key];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ - (id)valueForContainer:(id)container
} else if ([key isEqualToString:@"updatedAt"] || [key isEqualToString:@"_updated_at"]) {
return object.updatedAt;
} else {
return object[key];
return key ? object[key] : nil;
}
} else if ([container isKindOfClass:[NSDictionary class]]) {
return ((NSDictionary *)container)[key];
Expand Down
2 changes: 1 addition & 1 deletion Parse/Internal/Object/PFObjectPrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
@return Current object state.
*/
@property (nonatomic, copy) PFObjectState *_state;
@property (nonatomic, copy) NSMutableSet *_availableKeys;
@property (nonatomic, strong) NSMutableSet *_availableKeys;

- (instancetype)initWithObjectState:(PFObjectState *)state;
+ (instancetype)objectWithClassName:(NSString *)className
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,12 @@ - (void)_registerSubclassesInLoadedBundle:(NSBundle *)bundle {
}

- (void)_registerSubclassesInBundle:(NSBundle *)bundle {
PFConsistencyAssert(bundle.loaded, @"Cannot register subclasses in an unloaded bundle: %@", bundle);
// Prevent crash by loading the bundle if it's not loaded yet (see: https://github.com/ParsePlatform/Parse-SDK-iOS-OSX/issues/1006 ):
NSError *error = nil;
if (!bundle.loaded) {
[bundle loadAndReturnError:&error];
}
PFConsistencyAssert(bundle.loaded, @"Cannot register subclasses in a bundle that hasn't been loaded!");

const char *executablePath = bundle.executablePath.UTF8String;
if (executablePath == NULL) {
Expand Down
2 changes: 1 addition & 1 deletion Parse/Internal/Object/Utilities/PFObjectUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Operations
///--------------------------------------

+ (id)newValueByApplyingFieldOperation:(PFFieldOperation *)operation
+ (nullable id)newValueByApplyingFieldOperation:(PFFieldOperation *)operation
toDictionary:(NSMutableDictionary *)dictionary
forKey:(NSString *)key;
+ (void)applyOperationSet:(PFOperationSet *)operationSet toDictionary:(NSMutableDictionary *)dictionary;
Expand Down
2 changes: 1 addition & 1 deletion Parse/Internal/Object/Utilities/PFObjectUtilities.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ @implementation PFObjectUtilities
#pragma mark - Operations
///--------------------------------------

+ (id)newValueByApplyingFieldOperation:(PFFieldOperation *)operation
+ (nullable id)newValueByApplyingFieldOperation:(PFFieldOperation *)operation
toDictionary:(NSMutableDictionary *)dictionary
forKey:(NSString *)key {
id oldValue = dictionary[key];
Expand Down
2 changes: 1 addition & 1 deletion Parse/Internal/PFDateFormatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ NS_ASSUME_NONNULL_BEGIN

@return Formatted `NSString` representation.
*/
- (NSString *)preciseStringFromDate:(NSDate *)date;
- (nullable NSString *)preciseStringFromDate:(NSDate *)date;

///--------------------------------------
#pragma mark - Date from String
Expand Down
2 changes: 1 addition & 1 deletion Parse/Internal/PFDateFormatter.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ - (void)dealloc {
#pragma mark - String from Date
///--------------------------------------

- (NSString *)preciseStringFromDate:(NSDate *)date {
- (nullable NSString *)preciseStringFromDate:(NSDate *)date {
__block NSString *string = nil;
NSTimeInterval interval = date.timeIntervalSince1970;
dispatch_sync(_synchronizationQueue, ^{
Expand Down
4 changes: 3 additions & 1 deletion Parse/Internal/PFEventuallyQueue.m
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ - (instancetype)initWithDataSource:(id<PFCommandRunnerProvider>)dataSource
_commandEnqueueTaskQueue = [[PFTaskQueue alloc] init];

_taskCompletionSources = [NSMutableDictionary dictionary];
_testHelper = [[PFEventuallyQueueTestHelper alloc] init];

// we don't want your leaky test helper
// _testHelper = [[PFEventuallyQueueTestHelper alloc] init];

[self _startMonitoringNetworkReachability];

Expand Down
6 changes: 4 additions & 2 deletions Parse/Internal/PropertyInfo/PFPropertyInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ - (instancetype)initWithClass:(Class)kls name:(NSString *)propertyName
_ivar = class_getInstanceVariable(kls, safeStringWithPropertyAttributeValue(objcProperty, "V").UTF8String);
if (_ivar) break;

// Walk the superclass heirarchy for the property definition. Because property attributes are not inherited
// Walk the superclass hierarchy for the property definition. Because property attributes are not inherited
// (but property definitions *are*), we must be careful to ensure that the variable was never actually
// implemented and synthesized in a superclass. Note if the same property is synthesized in multiple classes
// with different iVars, we take the class furthest from the root class as the 'source of truth'.
Expand Down Expand Up @@ -94,7 +94,9 @@ - (instancetype)initWithClass:(Class)kls name:(NSString *)propertyName
propertySetter = [NSString stringWithFormat:@"set%@:", stringByCapitalizingFirstCharacter(_name)];
}

_setterSelector = NSSelectorFromString(propertySetter);
if (propertySetter != nil) {
_setterSelector = NSSelectorFromString(propertySetter);
}

if (_associationType == PFPropertyInfoAssociationTypeDefault) {
BOOL isCopy = safeStringWithPropertyAttributeValue(objcProperty, "C") != nil;
Expand Down
2 changes: 1 addition & 1 deletion Parse/Internal/Query/Controller/PFQueryController.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Caching
///--------------------------------------

- (NSString *)cacheKeyForQueryState:(PFQueryState *)queryState sessionToken:(nullable NSString *)sessionToken;
- (nullable NSString *)cacheKeyForQueryState:(PFQueryState *)queryState sessionToken:(nullable NSString *)sessionToken;
- (BOOL)hasCachedResultForQueryState:(PFQueryState *)queryState sessionToken:(nullable NSString *)sessionToken;

- (void)clearCachedResultForQueryState:(PFQueryState *)queryState sessionToken:(nullable NSString *)sessionToken;
Expand Down
2 changes: 1 addition & 1 deletion Parse/Internal/Query/Controller/PFQueryController.m
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ - (BFTask *)countObjectsAsyncForQueryState:(PFQueryState *)queryState
#pragma mark - Caching
///--------------------------------------

- (NSString *)cacheKeyForQueryState:(PFQueryState *)queryState sessionToken:(NSString *)sessionToken {
- (nullable NSString *)cacheKeyForQueryState:(PFQueryState *)queryState sessionToken:(NSString *)sessionToken {
return nil;
}

Expand Down
2 changes: 1 addition & 1 deletion Parse/Internal/Relation/State/PFMutableRelationState.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

@property (nonatomic, weak, readwrite) PFObject *parent;
@property (nonatomic, copy, readwrite) NSString *targetClass;
@property (nonatomic, copy, readwrite) NSMutableSet *knownObjects;
@property (nonatomic, strong, readwrite) NSMutableSet *knownObjects;
@property (nonatomic, copy, readwrite) NSString *key;

@end
2 changes: 1 addition & 1 deletion Parse/Internal/Relation/State/PFRelationState.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
@property (nonatomic, copy, readonly) NSString *parentClassName;
@property (nonatomic, copy, readonly) NSString *parentObjectId;
@property (nonatomic, copy, readonly) NSString *targetClass;
@property (nonatomic, copy, readonly) NSSet *knownObjects;
@property (nonatomic, strong, readonly) NSSet *knownObjects;
@property (nonatomic, copy, readonly) NSString *key;

///--------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion Parse/Internal/Relation/State/PFRelationState_Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
@property (nonatomic, copy, readwrite) NSString *parentClassName;
@property (nonatomic, copy, readwrite) NSString *parentObjectId;
@property (nonatomic, copy, readwrite) NSString *targetClass;
@property (nonatomic, copy, readwrite) NSSet *knownObjects;
@property (nonatomic, strong, readwrite) NSSet *knownObjects;
@property (nonatomic, copy, readwrite) NSString *key;

@end
15 changes: 10 additions & 5 deletions Parse/PFObject.m
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,9 @@ + (id)_objectFromDictionary:(NSDictionary *)dictionary
defaultClassName:defaultClassName
completeData:(selectedKeys == nil)
decoder:[PFDecoder objectDecoder]];
[result->_availableKeys addObjectsFromArray:selectedKeys];
if (selectedKeys) {
[result->_availableKeys addObjectsFromArray:selectedKeys];
}
return result;
}

Expand All @@ -789,7 +791,7 @@ + (id)_objectFromDictionary:(NSDictionary *)dictionary
@param decoder Decoder used to decode the dictionary.
*/
+ (id)_objectFromDictionary:(NSDictionary *)dictionary
defaultClassName:(NSString *)defaultClassName
defaultClassName:(nonnull NSString *)defaultClassName
completeData:(BOOL)completeData
decoder:(PFDecoder *)decoder {
NSString *objectId = nil;
Expand All @@ -798,7 +800,8 @@ + (id)_objectFromDictionary:(NSDictionary *)dictionary
objectId = dictionary[@"objectId"];
className = dictionary[@"className"] ?: defaultClassName;
}
PFObject *object = [PFObject objectWithoutDataWithClassName:className objectId:objectId];
// Temp fix for nil className possibility:
PFObject *object = [PFObject objectWithoutDataWithClassName:className ?: @"" objectId:objectId];
[object _mergeAfterFetchWithResult:dictionary decoder:decoder completeData:completeData];
return object;
}
Expand Down Expand Up @@ -964,7 +967,7 @@ - (void)mergeFromRESTDictionary:(NSDictionary *)object withDecoder:(PFDecoder *)
}

PFOperationSet *localOperationSet = [self unsavedChanges];
if (localOperationSet.updatedAt != nil &&
if (localOperationSet.updatedAt != nil && remoteOperationSet.updatedAt != nil &&
[localOperationSet.updatedAt compare:remoteOperationSet.updatedAt] != NSOrderedAscending) {
[localOperationSet mergeOperationSet:remoteOperationSet];
} else {
Expand Down Expand Up @@ -1304,7 +1307,9 @@ - (void)_mergeFromServerWithResult:(NSDictionary *)result decoder:(PFDecoder *)d
state.updatedAt = state.createdAt;
}
}];
[_availableKeys addObjectsFromArray:result.allKeys];
if (result.allKeys) {
[_availableKeys addObjectsFromArray:result.allKeys];
}

dirty = NO;
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/Other/Swift/SwiftSubclass.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class SwiftSubclass: PFObject, PFSubclassing {
@NSManaged public var primitiveProperty: Int
@NSManaged public var objectProperty: AnyObject?

@NSManaged public var relationProperty: PFRelation?
@NSManaged public var relationProperty: PFRelation<PFObject>?
@NSManaged public var badProperty: CGPoint

public static func parseClassName() -> String {
Expand Down
2 changes: 1 addition & 1 deletion Tests/Unit/ObjectSubclassingControllerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ - (void)testSwiftGetters {
[subclassingController forwardObjectInvocation:invocation withObject:target];
__unsafe_unretained PFRelation *returnValue = nil;
[invocation getReturnValue:&returnValue];
XCTAssertTrue([returnValue isKindOfClass:[PFRelation class]]);
XCTAssertTrue([returnValue isKindOfClass:[PFRelation class]], @"return value was %@", [returnValue class] ? NSStringFromClass([returnValue class]) : @"nil");

invocation = [self _forwardingInvocationForTarget:target
selector:@selector(badProperty)
Expand Down