no message
This commit is contained in:
1 parent
75966e2a94
commit
a11dc97ca9
9 files changed
+115
-87
No files matched your search
@@ -15,8 +15,9 @@
|
||||
|
||||
@property (nonatomic, strong) NSString *objID;
|
||||
@property (nonatomic, strong) NSDate *createdDate;
|
||||
@property (nonatomic, strong) NSDictionary *objectMapping;
|
||||
@property (nonatomic, strong, getter=getObject) NSDictionary *objectMapping;
|
||||
|
||||
- (instancetype) initWithJSON:(NSDictionary*) JSON;
|
||||
|
||||
+ (void) get;
|
||||
@end
|
||||
+32
-2
@@ -10,7 +10,7 @@
|
||||
#import <PNObjectProperty.h>
|
||||
#import <NSDate_Utils/NSDate+NSDate_Util.h>
|
||||
#import <AFNetworking/AFNetworking.h>
|
||||
#import "User/PNUser.h"
|
||||
#import "PNObject/PNUser.h"
|
||||
|
||||
@interface PNObject()
|
||||
|
||||
@@ -22,6 +22,32 @@
|
||||
|
||||
@implementation PNObject
|
||||
|
||||
|
||||
+ (void) get {
|
||||
|
||||
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
|
||||
manager.securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeCertificate];
|
||||
manager.securityPolicy.allowInvalidCertificates = YES;
|
||||
|
||||
[manager GET:[[[PNObjectConfig sharedInstance] PNObjEndpoint] stringByAppendingFormat:@"%@",@"User"] parameters:nil progress:nil success:^(NSURLSessionTask *task, id responseObject) {
|
||||
|
||||
|
||||
NSLog(@"JSON: %@", responseObject);
|
||||
NSLog(@"JSON: %@", [responseObject class]);
|
||||
|
||||
PNUser *user = [[PNUser alloc] initWithJSON:responseObject];
|
||||
|
||||
NSLog(@"%@",user);
|
||||
|
||||
|
||||
} failure:^(NSURLSessionTask *operation, NSError *error) {
|
||||
|
||||
NSLog(@"Error: %@", error);
|
||||
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
- (instancetype) init {
|
||||
self = [super init];
|
||||
|
||||
@@ -123,7 +149,7 @@
|
||||
else {
|
||||
BOOL isPNObjectSubclass = [NSClassFromString(propertyType) isSubclassOfClass:[PNObject class]];
|
||||
if(isPNObjectSubclass) {
|
||||
SEL selector = NSSelectorFromString(@"reverseMapping");
|
||||
SEL selector = NSSelectorFromString(@"getObject");
|
||||
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:
|
||||
[[PNObject class] instanceMethodSignatureForSelector:selector]];
|
||||
[invocation setSelector:selector];
|
||||
@@ -149,6 +175,10 @@
|
||||
return _JSON;
|
||||
}
|
||||
|
||||
- (NSDictionary*) getObject {
|
||||
return [self reverseMapping];
|
||||
}
|
||||
|
||||
- (void)populateObjectFromJSON:(id)JSON
|
||||
{
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
//
|
||||
|
||||
#import <PNObject/PNObject.h>
|
||||
#import "PNLocation.h"
|
||||
#import <PNObject/PNLocation.h>
|
||||
|
||||
@interface PNAddress : PNObject <PNObjectSubclassing>
|
||||
|
||||
|
||||
@@ -2,33 +2,18 @@
|
||||
// PNUser.h
|
||||
// Pods
|
||||
//
|
||||
// Created by Giuseppe Nucifora on 08/01/16.
|
||||
// Created by Giuseppe Nucifora on 15/01/16.
|
||||
//
|
||||
//
|
||||
|
||||
#import <PNObject/PNObject.h>
|
||||
#import "PNAddress.h"
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface PNUser : PNObject <PNObjectSubclassing>
|
||||
@interface PNUser : NSObject
|
||||
|
||||
@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 (nonatomic) BOOL hasAcceptedPrivacy;
|
||||
@property (nonatomic) BOOL hasAcceptedNewsletter;
|
||||
@property (nonatomic) BOOL hasVerifiedEmail;
|
||||
@property (nonatomic, strong) NSDate *emailVerifiedDate;
|
||||
@property (nonatomic, strong) NSString *email;
|
||||
@property (strong, nonatomic) NSString *username;
|
||||
@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;
|
||||
/**
|
||||
* gets singleton object.
|
||||
* @return singleton
|
||||
*/
|
||||
+ (PNUser*)sharedInstance;
|
||||
|
||||
@end
|
||||
+52
-46
@@ -2,7 +2,7 @@
|
||||
// PNUser.m
|
||||
// Pods
|
||||
//
|
||||
// Created by Giuseppe Nucifora on 08/01/16.
|
||||
// Created by Giuseppe Nucifora on 15/01/16.
|
||||
//
|
||||
//
|
||||
|
||||
@@ -10,54 +10,60 @@
|
||||
|
||||
@implementation PNUser
|
||||
|
||||
/*
|
||||
@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 (nonatomic) BOOL hasAcceptedPrivacy;
|
||||
@property (nonatomic) BOOL hasAcceptedNewsletter;
|
||||
@property (nonatomic) BOOL hasVerifiedEmail;
|
||||
@property (nonatomic, strong) NSDate *emailVerifiedDate;
|
||||
@property (nonatomic, strong) NSString *email;
|
||||
@property (strong, nonatomic) NSString *username;
|
||||
@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;
|
||||
*/
|
||||
static PNUser *SINGLETON = nil;
|
||||
|
||||
+ (NSDictionary *)objcetMapping {
|
||||
NSDictionary *mapping = @{@"userId":@"id",
|
||||
@"firstName":@"firstName",
|
||||
@"lastName":@"lastName",
|
||||
@"profileImage":@"profileImage",
|
||||
@"sex":@"sex",
|
||||
@"birthDate":@"birthDate",
|
||||
@"phone":@"phone",
|
||||
@"hasAcceptedPrivacy":@"hasAcceptedPrivacy",
|
||||
@"hasAcceptedNewsletter":@"hasAcceptedNewsletter",
|
||||
@"hasVerifiedEmail":@"hasVerifiedEmail",
|
||||
@"emailVerifiedDate":@"emailVerifiedDate",
|
||||
@"email":@"email",
|
||||
@"username":@"username",
|
||||
@"publicProfile":@"public_profile",
|
||||
@"loginCount":@"login_count",
|
||||
@"createdAt":@"created_at",
|
||||
@"facebookId":@"facebookId",
|
||||
@"facebookAccessToken":@"facebookAccessToken",
|
||||
@"address":@{@"key":@"address",@"type":@"PNAddress"}
|
||||
};
|
||||
return mapping;
|
||||
static bool isFirstAccess = YES;
|
||||
|
||||
#pragma mark - Public Method
|
||||
|
||||
+ (id)sharedInstance
|
||||
{
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
isFirstAccess = NO;
|
||||
SINGLETON = [[super allocWithZone:NULL] init];
|
||||
});
|
||||
|
||||
return SINGLETON;
|
||||
}
|
||||
|
||||
+ (NSString *)objectClassName {
|
||||
return @"User";
|
||||
#pragma mark - Life Cycle
|
||||
|
||||
+ (id) allocWithZone:(NSZone *)zone
|
||||
{
|
||||
return [self sharedInstance];
|
||||
}
|
||||
|
||||
+ (id)copyWithZone:(struct _NSZone *)zone
|
||||
{
|
||||
return [self sharedInstance];
|
||||
}
|
||||
|
||||
+ (id)mutableCopyWithZone:(struct _NSZone *)zone
|
||||
{
|
||||
return [self sharedInstance];
|
||||
}
|
||||
|
||||
- (id)copy
|
||||
{
|
||||
return [[PNUser alloc] init];
|
||||
}
|
||||
|
||||
- (id)mutableCopy
|
||||
{
|
||||
return [[PNUser alloc] init];
|
||||
}
|
||||
|
||||
- (id) init
|
||||
{
|
||||
if(SINGLETON){
|
||||
return SINGLETON;
|
||||
}
|
||||
if (isFirstAccess) {
|
||||
[self doesNotRecognizeSelector:_cmd];
|
||||
}
|
||||
self = [super init];
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user