commit
538b944026
@ -102,7 +102,7 @@
|
|||||||
|
|
||||||
- (void) apiCallAction {
|
- (void) apiCallAction {
|
||||||
|
|
||||||
PNObjcPassword *password = [PNObjcPassword new];
|
/*PNObjcPassword *password = [PNObjcPassword new];
|
||||||
[password setPassword:@"asdasdasd"];
|
[password setPassword:@"asdasdasd"];
|
||||||
[password setConfirmPassword:@"asdasdasd"];
|
[password setConfirmPassword:@"asdasdasd"];
|
||||||
|
|
||||||
@ -113,10 +113,10 @@
|
|||||||
[user setPassword:password];
|
[user setPassword:password];
|
||||||
[user setHasAcceptedNewsletter:YES];
|
[user setHasAcceptedNewsletter:YES];
|
||||||
[user setHasAcceptedPrivacy:YES];
|
[user setHasAcceptedPrivacy:YES];
|
||||||
|
*/
|
||||||
//[user saveLocally];
|
//[user saveLocally];
|
||||||
|
|
||||||
NSLog(@"%@",[user JSONFormObject]);
|
NSLog(@"%@",[[User currentUser] JSONFormObject]);
|
||||||
//NSLog(@"%@",[user JSONObjectMap]);
|
//NSLog(@"%@",[user JSONObjectMap]);
|
||||||
/*[user registerWithBlockSuccess:^(PNUser * _Nullable responseObject) {
|
/*[user registerWithBlockSuccess:^(PNUser * _Nullable responseObject) {
|
||||||
|
|
||||||
@ -138,10 +138,24 @@
|
|||||||
[User loginCurrentUserWithEmail:@"packman@giuseppenucifora.com" password:@"asdasdasd" withBlockSuccess:^(PNUser * _Nullable responseObject) {
|
[User loginCurrentUserWithEmail:@"packman@giuseppenucifora.com" password:@"asdasdasd" withBlockSuccess:^(PNUser * _Nullable responseObject) {
|
||||||
|
|
||||||
NSLog(@"response : %@",responseObject);
|
NSLog(@"response : %@",responseObject);
|
||||||
|
|
||||||
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||||
|
[responseObject reloadFormServer];
|
||||||
|
});
|
||||||
} failure:^(NSError * _Nonnull error) {
|
} failure:^(NSError * _Nonnull error) {
|
||||||
NSLog(@"response : %@",error);
|
NSLog(@"response : %@",error);
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*[User resetPasswordForEmail:@"packman@giuseppenucifora.com" Progress:^(NSProgress * _Nonnull uploadProgress) {
|
||||||
|
|
||||||
|
} Success:^(NSDictionary * _Nullable responseObject) {
|
||||||
|
|
||||||
|
} failure:^(NSError * _Nonnull error) {
|
||||||
|
|
||||||
|
}];*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)didReceiveMemoryWarning
|
- (void)didReceiveMemoryWarning
|
||||||
|
|||||||
@ -95,7 +95,7 @@ static bool isFirstAccess = YES;
|
|||||||
NSDictionary *savedInstallation = [[PNObjectModel sharedInstance] fetchObjectsWithClass:[self class]];
|
NSDictionary *savedInstallation = [[PNObjectModel sharedInstance] fetchObjectsWithClass:[self class]];
|
||||||
|
|
||||||
if (savedInstallation) {
|
if (savedInstallation) {
|
||||||
self = [super initWithJSON:savedInstallation];
|
self = [super initWithLocalJSON:savedInstallation];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
self = [super init];
|
self = [super init];
|
||||||
|
|||||||
@ -75,7 +75,7 @@ static bool isFirstAccess = YES;
|
|||||||
NSDictionary *savedUser = [[PNObjectModel sharedInstance] fetchObjectsWithClass:[self class]];
|
NSDictionary *savedUser = [[PNObjectModel sharedInstance] fetchObjectsWithClass:[self class]];
|
||||||
|
|
||||||
if (savedUser) {
|
if (savedUser) {
|
||||||
USER = [super initWithJSON:savedUser];
|
USER = [super initWithLocalJSON:savedUser];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (USER) {
|
if (USER) {
|
||||||
@ -136,11 +136,15 @@ static bool isFirstAccess = YES;
|
|||||||
///api/v1/user/profile
|
///api/v1/user/profile
|
||||||
|
|
||||||
[self autoLoginWithBlockSuccess:^(BOOL loginSuccess) {
|
[self autoLoginWithBlockSuccess:^(BOOL loginSuccess) {
|
||||||
[self GETWithEndpointAction:@"user/profile"
|
[[self class] GETWithEndpointAction:@"user/profile"
|
||||||
progress:nil
|
progress:nil
|
||||||
success:^(NSURLSessionDataTask * _Nullable task, id _Nullable responseObject) {
|
success:^(NSURLSessionDataTask * _Nullable task, id _Nullable responseObject) {
|
||||||
|
|
||||||
NSLogDebug(@"%@",responseObject);
|
NSLogDebug(@"%@",[responseObject objectForKey:@"user"]);
|
||||||
|
|
||||||
|
[self populateObjectFromJSON:[responseObject objectForKey:@"user"]];
|
||||||
|
[self saveLocally];
|
||||||
|
|
||||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||||
NSLogDebug(@"%@",error);
|
NSLogDebug(@"%@",error);
|
||||||
}];
|
}];
|
||||||
@ -152,7 +156,7 @@ static bool isFirstAccess = YES;
|
|||||||
- (void) registerWithBlockSuccess:(nullable void (^)(PNUser * _Nullable responseObject))success
|
- (void) registerWithBlockSuccess:(nullable void (^)(PNUser * _Nullable responseObject))success
|
||||||
failure:(nullable void (^)(NSError * _Nonnull error))failure {
|
failure:(nullable void (^)(NSError * _Nonnull error))failure {
|
||||||
|
|
||||||
[self POSTWithEndpointAction:@"registration/register" parameters:[self JSONFormObject]
|
[[self class] POSTWithEndpointAction:@"registration/register" parameters:[self JSONFormObject]
|
||||||
progress:nil
|
progress:nil
|
||||||
success:^(NSURLSessionDataTask * _Nullable task, NSDictionary * _Nullable responseObject) {
|
success:^(NSURLSessionDataTask * _Nullable task, NSDictionary * _Nullable responseObject) {
|
||||||
NSLog(@"response %@",responseObject);
|
NSLog(@"response %@",responseObject);
|
||||||
@ -295,23 +299,23 @@ static bool isFirstAccess = YES;
|
|||||||
|
|
||||||
NSDictionary *mapping = @{
|
NSDictionary *mapping = @{
|
||||||
@"userId":@"uuid",
|
@"userId":@"uuid",
|
||||||
@"firstName":@"firstName",
|
@"firstName":@"first_name",
|
||||||
@"lastName":@"lastName",
|
@"lastName":@"last_name",
|
||||||
@"profileImage":@"profileImage",
|
@"profileImage":@"profile_image",
|
||||||
@"sex":@"sex",
|
@"sex":@"sex",
|
||||||
@"birthDate":@"birthDate",
|
@"birthDate":@"birth_year",
|
||||||
@"phone":@"phone",
|
@"phone":@"phone",
|
||||||
@"password":@{@"key":@"password",@"type":@"PNObjcPassword"},
|
@"password":@{@"key":@"password",@"type":@"PNObjcPassword"},
|
||||||
@"hasAcceptedPrivacy":@"hasAcceptedPrivacy",
|
@"hasAcceptedPrivacy":@"has_accepted_privacy",
|
||||||
@"hasAcceptedNewsletter":@"hasAcceptedNewsletter",
|
@"hasAcceptedNewsletter":@"has_accepted_newsletter",
|
||||||
@"hasVerifiedEmail":@"hasVerifiedEmail",
|
@"hasVerifiedEmail":@"has_verified_email",
|
||||||
@"hasVerifiedPhone":@"has_verified_phone",
|
@"hasVerifiedPhone":@"has_verified_phone",
|
||||||
@"emailVerifiedDate":@"emailVerifiedDate",
|
@"emailVerifiedDate":@"email_verified_date",
|
||||||
@"email":@"email",
|
@"email":@"email",
|
||||||
@"username":@"username",
|
@"username":@"username",
|
||||||
@"publicProfile":@"publicProfile",
|
@"publicProfile":@"publicProfile",
|
||||||
@"loginCount":@"login_count",
|
@"loginCount":@"login_count",
|
||||||
@"facebookId":@"facebookId",
|
@"facebookId":@"facebook_id",
|
||||||
@"facebookAccessToken":@"facebookAccessToken",
|
@"facebookAccessToken":@"facebookAccessToken",
|
||||||
@"isFacebookUser":@"isFacebookUser",
|
@"isFacebookUser":@"isFacebookUser",
|
||||||
@"registeredAt":@"registeredAt",
|
@"registeredAt":@"registeredAt",
|
||||||
|
|||||||
@ -11,14 +11,14 @@
|
|||||||
@interface PNObject (PNObjectConnection)
|
@interface PNObject (PNObjectConnection)
|
||||||
|
|
||||||
|
|
||||||
- (void) GETWithEndpointAction:(NSString * _Nonnull) endPoint
|
+ (void) GETWithEndpointAction:(NSString * _Nonnull) endPoint
|
||||||
progress:(nullable void (^)(NSProgress * _Nonnull downloadProgress)) downloadProgress
|
progress:(nullable void (^)(NSProgress * _Nullable downloadProgress)) downloadProgress
|
||||||
success:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSDictionary * _Nullable responseObject))success
|
success:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSDictionary * _Nullable responseObject))success
|
||||||
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error))failure;
|
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error))failure;
|
||||||
|
|
||||||
- (void) POSTWithEndpointAction:(NSString * _Nonnull) endPoint
|
+ (void) POSTWithEndpointAction:(NSString * _Nonnull) endPoint
|
||||||
parameters:(NSDictionary * _Nonnull) parameters
|
parameters:(NSDictionary * _Nullable) parameters
|
||||||
progress:(nullable void (^)(NSProgress * _Nonnull uploadProgress)) uploadProgress
|
progress:(nullable void (^)(NSProgress * _Nullable uploadProgress)) uploadProgress
|
||||||
success:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSDictionary * _Nullable responseObject))success
|
success:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSDictionary * _Nullable responseObject))success
|
||||||
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error))failure;
|
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error))failure;
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
@implementation PNObject (PNObjectConnection)
|
@implementation PNObject (PNObjectConnection)
|
||||||
|
|
||||||
- (void) GETWithEndpointAction:(NSString * _Nonnull) endPoint
|
+ (void) GETWithEndpointAction:(NSString * _Nonnull) endPoint
|
||||||
progress:(nullable void (^)(NSProgress * _Nonnull downloadProgress)) downloadProgress
|
progress:(nullable void (^)(NSProgress * _Nonnull downloadProgress)) downloadProgress
|
||||||
success:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSDictionary * _Nullable responseObject))success
|
success:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSDictionary * _Nullable responseObject))success
|
||||||
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error))failure {
|
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error))failure {
|
||||||
@ -48,8 +48,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) POSTWithEndpointAction:(NSString * _Nonnull) endPoint
|
+ (void) POSTWithEndpointAction:(NSString * _Nonnull) endPoint
|
||||||
parameters:(NSDictionary * _Nonnull) parameters
|
parameters:(NSDictionary * _Nullable) parameters
|
||||||
progress:(nullable void (^)(NSProgress * _Nonnull uploadProgress)) uploadProgress
|
progress:(nullable void (^)(NSProgress * _Nonnull uploadProgress)) uploadProgress
|
||||||
success:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSDictionary * _Nullable responseObject))success
|
success:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSDictionary * _Nullable responseObject))success
|
||||||
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error))failure {
|
failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error))failure {
|
||||||
@ -91,14 +91,14 @@
|
|||||||
if (response) {
|
if (response) {
|
||||||
|
|
||||||
if ([response isKindOfClass:[NSDictionary class]] && [[response allKeys] count] > 0) {
|
if ([response isKindOfClass:[NSDictionary class]] && [[response allKeys] count] > 0) {
|
||||||
PNObjectResponse = [[[self class] alloc] initWithJSON:[response copy]];
|
PNObjectResponse = [[[self class] alloc] initWithRemoteJSON:[response copy]];
|
||||||
}
|
}
|
||||||
else if ([response isKindOfClass:[NSArray class]] && [response count] > 0){
|
else if ([response isKindOfClass:[NSArray class]] && [response count] > 0){
|
||||||
|
|
||||||
NSMutableArray * resposeArray = [[NSMutableArray alloc] init];
|
NSMutableArray * resposeArray = [[NSMutableArray alloc] init];
|
||||||
for (id singleObjectDict in response) {
|
for (id singleObjectDict in response) {
|
||||||
if ([singleObjectDict isKindOfClass:[NSDictionary class]]) {
|
if ([singleObjectDict isKindOfClass:[NSDictionary class]]) {
|
||||||
id singleObject = [[[self class] alloc] initWithJSON:singleObjectDict];
|
id singleObject = [[[self class] alloc] initWithRemoteJSON:singleObjectDict];
|
||||||
[resposeArray addObject:singleObject];
|
[resposeArray addObject:singleObject];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,6 +23,15 @@ extern NSString* _Nonnull const PNObjectMappingSelector;
|
|||||||
* @param JSON <#JSON description#>
|
* @param JSON <#JSON description#>
|
||||||
*/
|
*/
|
||||||
- (void)populateObjectFromJSON:(id _Nullable)JSON;
|
- (void)populateObjectFromJSON:(id _Nullable)JSON;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <#Description#>
|
||||||
|
*
|
||||||
|
* @param JSON <#JSON description#>
|
||||||
|
* @param fromLocal <#fromLocal description#>
|
||||||
|
*/
|
||||||
|
- (void) populateObjectFromJSON:(id _Nullable)JSON fromLocal:(BOOL) fromLocal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <#Description#>
|
* <#Description#>
|
||||||
*
|
*
|
||||||
@ -31,12 +40,14 @@ extern NSString* _Nonnull const PNObjectMappingSelector;
|
|||||||
* @return <#return value description#>
|
* @return <#return value description#>
|
||||||
*/
|
*/
|
||||||
- (BOOL)isObjNull:(id _Nullable)obj;
|
- (BOOL)isObjNull:(id _Nullable)obj;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <#Description#>
|
* <#Description#>
|
||||||
*
|
*
|
||||||
* @return <#return value description#>
|
* @return <#return value description#>
|
||||||
*/
|
*/
|
||||||
+ (NSArray * _Nonnull) protectedProperties;
|
+ (NSArray * _Nonnull) protectedProperties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <#Description#>
|
* <#Description#>
|
||||||
*
|
*
|
||||||
|
|||||||
@ -30,8 +30,12 @@ NSString * const PNObjectMappingSelector = @"PNObjectLocalNotificationRefreshTok
|
|||||||
return @[@"JSON",@"objectModel",@"objectMapping",@"singleInstance"];
|
return @[@"JSON",@"objectModel",@"objectMapping",@"singleInstance"];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)populateObjectFromJSON:(id _Nullable)JSON
|
- (void) populateObjectFromJSON:(id)JSON {
|
||||||
{
|
return [self populateObjectFromJSON:JSON fromLocal:NO];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) populateObjectFromJSON:(id _Nullable)JSON fromLocal:(BOOL) fromLocal {
|
||||||
|
|
||||||
NSDictionary *properties = [PNObject propertiesForClass:self.class];
|
NSDictionary *properties = [PNObject propertiesForClass:self.class];
|
||||||
|
|
||||||
for(NSString *propertyName in properties) {
|
for(NSString *propertyName in properties) {
|
||||||
@ -46,7 +50,6 @@ NSString * const PNObjectMappingSelector = @"PNObjectLocalNotificationRefreshTok
|
|||||||
|
|
||||||
id mappingValue = [[[self class] objcetMapping] valueForKey:propertyName];
|
id mappingValue = [[[self class] objcetMapping] valueForKey:propertyName];
|
||||||
|
|
||||||
|
|
||||||
if([mappingValue isKindOfClass:NSDictionary.class]) {
|
if([mappingValue isKindOfClass:NSDictionary.class]) {
|
||||||
mappedJSONKey = [mappingValue valueForKey:@"key"];
|
mappedJSONKey = [mappingValue valueForKey:@"key"];
|
||||||
mappedJSONType = [mappingValue valueForKey:@"type"];
|
mappedJSONType = [mappingValue valueForKey:@"type"];
|
||||||
@ -54,13 +57,23 @@ NSString * const PNObjectMappingSelector = @"PNObjectLocalNotificationRefreshTok
|
|||||||
mappedJSONKey = mappingValue;
|
mappedJSONKey = mappingValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*if (fromLocal) {
|
||||||
|
propertyName = mappedJSONKey;
|
||||||
|
}*/
|
||||||
|
|
||||||
if ([[PNObject protectedProperties] containsObject:propertyName] || [self isObjNull:mappedJSONKey]) {
|
if ([[PNObject protectedProperties] containsObject:propertyName] || [self isObjNull:mappedJSONKey]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get JSON value for the mapped key
|
// Get JSON value for the mapped key
|
||||||
id value = [JSON valueForKeyPath:mappedJSONKey];
|
id value;
|
||||||
|
if (fromLocal) {
|
||||||
|
value = [JSON valueForKeyPath:propertyName];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
value = [JSON valueForKeyPath:mappedJSONKey];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if([self isObjNull:value]) {
|
if([self isObjNull:value]) {
|
||||||
continue;
|
continue;
|
||||||
@ -121,7 +134,7 @@ NSString * const PNObjectMappingSelector = @"PNObjectLocalNotificationRefreshTok
|
|||||||
@"NSArray" : ^{
|
@"NSArray" : ^{
|
||||||
NSMutableArray *arr = [NSMutableArray array];
|
NSMutableArray *arr = [NSMutableArray array];
|
||||||
for(id JSONObject in value) {
|
for(id JSONObject in value) {
|
||||||
PNObject *val = [[NSClassFromString(mappedJSONType) alloc] initWithJSON:JSONObject];
|
PNObject *val = [[NSClassFromString(mappedJSONType) alloc] initWithJSON:JSONObject fromLocal:fromLocal];
|
||||||
[arr addObject:val];
|
[arr addObject:val];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,7 +143,7 @@ NSString * const PNObjectMappingSelector = @"PNObjectLocalNotificationRefreshTok
|
|||||||
@"NSMutableArray" : ^{
|
@"NSMutableArray" : ^{
|
||||||
NSMutableArray *arr = [NSMutableArray array];
|
NSMutableArray *arr = [NSMutableArray array];
|
||||||
for(id JSONObject in value) {
|
for(id JSONObject in value) {
|
||||||
PNObject *val = [[NSClassFromString(mappedJSONType) alloc] initWithJSON:JSONObject];
|
PNObject *val = [[NSClassFromString(mappedJSONType) alloc] initWithJSON:JSONObject fromLocal:fromLocal];
|
||||||
[arr addObject:val];
|
[arr addObject:val];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,7 +155,7 @@ NSString * const PNObjectMappingSelector = @"PNObjectLocalNotificationRefreshTok
|
|||||||
|
|
||||||
if(isPNObjectSubclass) {
|
if(isPNObjectSubclass) {
|
||||||
|
|
||||||
PNObject *val = [[NSClassFromString(propertyType) alloc] initWithJSON:value];
|
PNObject *val = [[NSClassFromString(propertyType) alloc] initWithJSON:value fromLocal:fromLocal];
|
||||||
[self setValue:val forKey:propertyName];
|
[self setValue:val forKey:propertyName];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@ -32,9 +32,13 @@
|
|||||||
|
|
||||||
+ (NSString * _Nonnull) PNObjEndPoint;
|
+ (NSString * _Nonnull) PNObjEndPoint;
|
||||||
|
|
||||||
+ (NSArray * _Nonnull) batch:(id _Nonnull)JSON;
|
+ (NSArray * _Nonnull) batch:(id _Nonnull)JSON fromLocal:(BOOL) fromLocal;
|
||||||
|
|
||||||
- (_Nullable instancetype) initWithJSON:( NSDictionary * _Nonnull) JSON;
|
- (_Nullable instancetype) initWithLocalJSON:( NSDictionary * _Nonnull) JSON;
|
||||||
|
|
||||||
|
- (_Nullable instancetype) initWithRemoteJSON:( NSDictionary * _Nonnull) JSON;
|
||||||
|
|
||||||
|
- (_Nullable instancetype) initWithJSON:( NSDictionary * _Nonnull) JSON fromLocal:(BOOL) fromLocal;
|
||||||
|
|
||||||
- (id _Nonnull) saveLocally;
|
- (id _Nonnull) saveLocally;
|
||||||
|
|
||||||
|
|||||||
@ -114,7 +114,16 @@
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (_Nullable instancetype) initWithJSON:( NSDictionary * _Nonnull) JSON {
|
- (_Nullable instancetype) initWithRemoteJSON:( NSDictionary * _Nonnull) JSON {
|
||||||
|
return [self initWithJSON:JSON fromLocal:NO];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (_Nullable instancetype) initWithLocalJSON:( NSDictionary * _Nonnull) JSON {
|
||||||
|
return [self initWithJSON:JSON fromLocal:YES];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (_Nullable instancetype) initWithJSON:( NSDictionary * _Nonnull) JSON fromLocal:(BOOL) fromLocal {
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self) {
|
if (self) {
|
||||||
if ([[self class] isSubclassOfClass:[PNObject class]]) {
|
if ([[self class] isSubclassOfClass:[PNObject class]]) {
|
||||||
@ -150,14 +159,14 @@
|
|||||||
NSAssert(self.JSONObjectMap, @"You must create objectMapping");
|
NSAssert(self.JSONObjectMap, @"You must create objectMapping");
|
||||||
self.JSON = [[NSMutableDictionary alloc] initWithDictionary:JSON];
|
self.JSON = [[NSMutableDictionary alloc] initWithDictionary:JSON];
|
||||||
|
|
||||||
[self populateObjectFromJSON:self.JSON];
|
[self populateObjectFromJSON:self.JSON fromLocal:fromLocal];
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSDictionary * _Nonnull) reverseMapping
|
- (NSDictionary * _Nonnull) reverseMapping
|
||||||
{
|
{
|
||||||
NSMutableDictionary *JSON = [NSMutableDictionary dictionary];
|
NSMutableDictionary *JSON = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
NSString *mappedJSONKey;
|
NSString *mappedJSONKey;
|
||||||
NSString *mappedJSONType;
|
NSString *mappedJSONType;
|
||||||
@ -350,14 +359,14 @@
|
|||||||
return [self.objectModel removeObjectLocally:self];
|
return [self.objectModel removeObjectLocally:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSArray *)batch:(id)JSON
|
+ (NSArray *)batch:(id)JSON fromLocal:(BOOL) fromLocal
|
||||||
{
|
{
|
||||||
NSString *className = NSStringFromClass([self class]);
|
NSString *className = NSStringFromClass([self class]);
|
||||||
|
|
||||||
NSMutableArray *batch = [NSMutableArray array];
|
NSMutableArray *batch = [NSMutableArray array];
|
||||||
|
|
||||||
for(id objectJSON in JSON) {
|
for(id objectJSON in JSON) {
|
||||||
PNObject *val = [[NSClassFromString(className) alloc] initWithJSON:objectJSON];
|
PNObject *val = [[NSClassFromString(className) alloc] initWithJSON:objectJSON fromLocal:fromLocal];
|
||||||
[batch addObject:val];
|
[batch addObject:val];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -172,7 +172,6 @@ static bool isFirstAccess = YES;
|
|||||||
|
|
||||||
NSData *objectData = [RNCryptor encryptData:[NSKeyedArchiver archivedDataWithRootObject:objectDict] password:[[PNObjectConfig sharedInstance] encrypKey]];
|
NSData *objectData = [RNCryptor encryptData:[NSKeyedArchiver archivedDataWithRootObject:objectDict] password:[[PNObjectConfig sharedInstance] encrypKey]];
|
||||||
|
|
||||||
|
|
||||||
if ([self issetPNObjectModelForObject:object]) {
|
if ([self issetPNObjectModelForObject:object]) {
|
||||||
if ([_fileManager updateFileWithData:objectData filePath:[self objectName:object] permisson:@(0755)]) {
|
if ([_fileManager updateFileWithData:objectData filePath:[self objectName:object] permisson:@(0755)]) {
|
||||||
return object;
|
return object;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user