no message
This commit is contained in:
parent
75966e2a94
commit
a11dc97ca9
@ -8,6 +8,7 @@
|
||||
|
||||
#import "PNObjectAppDelegate.h"
|
||||
#import "PNObject.h"
|
||||
#import "PNUser.h"
|
||||
|
||||
@implementation PNObjectAppDelegate
|
||||
|
||||
@ -24,6 +25,12 @@
|
||||
|
||||
[PNObject get];*/
|
||||
|
||||
/*PNUser *user = [PNUser sharedInstance];
|
||||
[user setFirstName:@"peppe"];
|
||||
[user setLastName:@"nucifora"];
|
||||
|
||||
NSLog(@"user : %@",[user getObject]);
|
||||
*/
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
@ -7,7 +7,6 @@
|
||||
//
|
||||
|
||||
#import "PNObjectViewController.h"
|
||||
//#import "PNObject.h"
|
||||
|
||||
|
||||
@interface PNObjectViewController ()
|
||||
|
||||
8
Example/Pods/Pods.xcodeproj/project.pbxproj
generated
8
Example/Pods/Pods.xcodeproj/project.pbxproj
generated
@ -1475,14 +1475,14 @@
|
||||
isa = PBXHeadersBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
CAC4420D53FB5288CEBCE296412C16CB /* PNAddress.h in Headers */,
|
||||
EA8E630DD2C78A4A5DC0F8DEF3484D62 /* PNLocation.h in Headers */,
|
||||
941354E1B678B9221BD1C15EE37BA55E /* PNObject-umbrella.h in Headers */,
|
||||
295C2B75DF7492F4AF35CDF93891E816 /* PNObject.h in Headers */,
|
||||
CE706AD64F95B815E15F7154C20C9B8C /* PNObjectConfig.h in Headers */,
|
||||
0149AF8689F2AAE11A2E689E6EE912DD /* PNObjectProperty.h in Headers */,
|
||||
5D8BB0A730FC0A0AE17B84459F953E5F /* PNObjectSubclassing.h in Headers */,
|
||||
CE706AD64F95B815E15F7154C20C9B8C /* PNObjectConfig.h in Headers */,
|
||||
F6BB55A8386E361E9D22492FB3C2E868 /* PNUser.h in Headers */,
|
||||
CAC4420D53FB5288CEBCE296412C16CB /* PNAddress.h in Headers */,
|
||||
EA8E630DD2C78A4A5DC0F8DEF3484D62 /* PNLocation.h in Headers */,
|
||||
0149AF8689F2AAE11A2E689E6EE912DD /* PNObjectProperty.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
buildForArchiving = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = 'primary'
|
||||
BlueprintIdentifier = 'F6218C00F6F447EBE8284238'
|
||||
BlueprintIdentifier = '0565015C916AAA8DF9B9CE0C'
|
||||
BlueprintName = 'PNObject'
|
||||
ReferencedContainer = 'container:Pods.xcodeproj'
|
||||
BuildableName = 'PNObject.framework'>
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user