diff --git a/Pod/Classes/PNObjectModel.m b/Pod/Classes/PNObjectModel.m index 20bfc3e..4674ab9 100644 --- a/Pod/Classes/PNObjectModel.m +++ b/Pod/Classes/PNObjectModel.m @@ -170,7 +170,20 @@ static bool isFirstAccess = YES; } - (void) saveLocally:(id _Nonnull) object inBackGroundWithBlock:(nullable void (^)(BOOL saveStatus, id _Nullable responseObject, NSError * _Nullable error)) responseBlock { - + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + + __weak id responseObject = [self saveLocally:object]; + if ([responseObject isKindOfClass:[NSError class]]) { + if (responseBlock) { + responseBlock(NO, nil, responseObject); + } + } + else if ([[responseObject class] isSubclassOfClass:[PNObject class]]){ + if (responseBlock) { + responseBlock(YES,responseObject, nil); + } + } + }); } - (id _Nonnull) pushObjectAndSaveLocally:(id _Nonnull) object { diff --git a/Pod/Classes/User/PNAddress.h b/Pod/Classes/User/PNAddress.h index 3f2ebef..ad8207e 100644 --- a/Pod/Classes/User/PNAddress.h +++ b/Pod/Classes/User/PNAddress.h @@ -11,13 +11,13 @@ @interface PNAddress : PNObject -@property (nonatomic, strong) NSString *country; -@property (nonatomic, strong) NSString *province; -@property (nonatomic, strong) NSString *city; -@property (nonatomic, strong) NSString *street; -@property (nonatomic, strong) NSNumber *number; -@property (nonatomic, strong) NSString *zip; -@property (nonatomic, strong) NSString *istruction; -@property (nonatomic, strong) PNLocation *location; +@property (nonatomic, strong) NSString * _Nullable country; +@property (nonatomic, strong) NSString * _Nullable province; +@property (nonatomic, strong) NSString * _Nullable city; +@property (nonatomic, strong) NSString * _Nullable street; +@property (nonatomic, strong) NSNumber * _Nullable number; +@property (nonatomic, strong) NSString * _Nullable zip; +@property (nonatomic, strong) NSString * _Nullable istruction; +@property (nonatomic, strong) PNLocation * _Nullable location; @end diff --git a/Pod/Classes/User/PNUser.h b/Pod/Classes/User/PNUser.h index b17fdaf..28cb748 100644 --- a/Pod/Classes/User/PNUser.h +++ b/Pod/Classes/User/PNUser.h @@ -7,37 +7,37 @@ // #import "PNObject.h" -#import "PNAddress.h" + @interface PNUser : PNObject -@property (strong, nonatomic) NSString *userId; -@property (strong, nonatomic) NSString *firstName; -@property (strong, nonatomic) NSString *lastName; -@property (nonatomic, strong) NSString *profileImage; -@property (nonatomic, strong) NSString *sex; -@property (nonatomic, strong) NSDate *birthDate; -@property (nonatomic, strong) NSString *phone; +@property (strong, nonatomic) NSString * _Nonnull userId; +@property (strong, nonatomic) NSString * _Nonnull firstName; +@property (strong, nonatomic) NSString * _Nonnull lastName; +@property (nonatomic, strong) NSString * _Nullable profileImage; +@property (nonatomic, strong) NSString * _Nullable sex; +@property (nonatomic, strong) NSDate * _Nullable birthDate; +@property (nonatomic, strong) NSString * _Nullable phone; @property (nonatomic) BOOL hasAcceptedPrivacy; @property (nonatomic) BOOL hasAcceptedNewsletter; @property (nonatomic) BOOL hasVerifiedEmail; -@property (nonatomic, strong) NSDate *emailVerifiedDate; -@property (nonatomic, strong) NSString *email; -@property (nonatomic, strong) NSString *username; -@property (nonatomic, strong) NSString *password; +@property (nonatomic, strong) NSDate * _Nullable emailVerifiedDate; +@property (nonatomic, strong) NSString * _Nonnull email; +@property (nonatomic, strong) NSString * _Nonnull username; +@property (nonatomic, strong) NSString * _Nonnull password; @property (nonatomic) BOOL publicProfile; @property (nonatomic) NSInteger loginCount; -@property (strong, nonatomic) NSDate *createdAt; -@property (nonatomic, strong) NSString *facebookId; -@property (nonatomic, strong) NSString *facebookAccessToken; -@property (nonatomic, strong) PNAddress *address; +@property (strong, nonatomic) NSDate * _Nonnull createdAt; +@property (nonatomic, strong) NSString * _Nullable facebookId; +@property (nonatomic, strong) NSString * _Nullable facebookAccessToken; + /** * gets singleton object of current user session. * * @return singleton */ -+ (instancetype) currentUser; ++ (instancetype _Nonnull) currentUser; - (BOOL) isValidPassword:(NSString* _Nonnull) password; diff --git a/Pod/Classes/User/PNUser.m b/Pod/Classes/User/PNUser.m index 560369f..03bdc5d 100644 --- a/Pod/Classes/User/PNUser.m +++ b/Pod/Classes/User/PNUser.m @@ -130,7 +130,6 @@ static bool isFirstAccess = YES; @"createdAt":@"created_at", @"facebookId":@"facebookId", @"facebookAccessToken":@"facebookAccessToken", - @"address":@{@"key":@"address",@"type":@"PNAddress"} }; return mapping; }