no message
This commit is contained in:
parent
75966e2a94
commit
a11dc97ca9
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#import "PNObjectAppDelegate.h"
|
#import "PNObjectAppDelegate.h"
|
||||||
#import "PNObject.h"
|
#import "PNObject.h"
|
||||||
|
#import "PNUser.h"
|
||||||
|
|
||||||
@implementation PNObjectAppDelegate
|
@implementation PNObjectAppDelegate
|
||||||
|
|
||||||
@ -24,6 +25,12 @@
|
|||||||
|
|
||||||
[PNObject get];*/
|
[PNObject get];*/
|
||||||
|
|
||||||
|
/*PNUser *user = [PNUser sharedInstance];
|
||||||
|
[user setFirstName:@"peppe"];
|
||||||
|
[user setLastName:@"nucifora"];
|
||||||
|
|
||||||
|
NSLog(@"user : %@",[user getObject]);
|
||||||
|
*/
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,6 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import "PNObjectViewController.h"
|
#import "PNObjectViewController.h"
|
||||||
//#import "PNObject.h"
|
|
||||||
|
|
||||||
|
|
||||||
@interface PNObjectViewController ()
|
@interface PNObjectViewController ()
|
||||||
|
|||||||
8
Example/Pods/Pods.xcodeproj/project.pbxproj
generated
8
Example/Pods/Pods.xcodeproj/project.pbxproj
generated
@ -1475,14 +1475,14 @@
|
|||||||
isa = PBXHeadersBuildPhase;
|
isa = PBXHeadersBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
CAC4420D53FB5288CEBCE296412C16CB /* PNAddress.h in Headers */,
|
|
||||||
EA8E630DD2C78A4A5DC0F8DEF3484D62 /* PNLocation.h in Headers */,
|
|
||||||
941354E1B678B9221BD1C15EE37BA55E /* PNObject-umbrella.h in Headers */,
|
941354E1B678B9221BD1C15EE37BA55E /* PNObject-umbrella.h in Headers */,
|
||||||
295C2B75DF7492F4AF35CDF93891E816 /* PNObject.h in Headers */,
|
295C2B75DF7492F4AF35CDF93891E816 /* PNObject.h in Headers */,
|
||||||
CE706AD64F95B815E15F7154C20C9B8C /* PNObjectConfig.h in Headers */,
|
|
||||||
0149AF8689F2AAE11A2E689E6EE912DD /* PNObjectProperty.h in Headers */,
|
|
||||||
5D8BB0A730FC0A0AE17B84459F953E5F /* PNObjectSubclassing.h in Headers */,
|
5D8BB0A730FC0A0AE17B84459F953E5F /* PNObjectSubclassing.h in Headers */,
|
||||||
|
CE706AD64F95B815E15F7154C20C9B8C /* PNObjectConfig.h in Headers */,
|
||||||
F6BB55A8386E361E9D22492FB3C2E868 /* PNUser.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;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
buildForArchiving = "YES">
|
buildForArchiving = "YES">
|
||||||
<BuildableReference
|
<BuildableReference
|
||||||
BuildableIdentifier = 'primary'
|
BuildableIdentifier = 'primary'
|
||||||
BlueprintIdentifier = 'F6218C00F6F447EBE8284238'
|
BlueprintIdentifier = '0565015C916AAA8DF9B9CE0C'
|
||||||
BlueprintName = 'PNObject'
|
BlueprintName = 'PNObject'
|
||||||
ReferencedContainer = 'container:Pods.xcodeproj'
|
ReferencedContainer = 'container:Pods.xcodeproj'
|
||||||
BuildableName = 'PNObject.framework'>
|
BuildableName = 'PNObject.framework'>
|
||||||
|
|||||||
@ -15,8 +15,9 @@
|
|||||||
|
|
||||||
@property (nonatomic, strong) NSString *objID;
|
@property (nonatomic, strong) NSString *objID;
|
||||||
@property (nonatomic, strong) NSDate *createdDate;
|
@property (nonatomic, strong) NSDate *createdDate;
|
||||||
@property (nonatomic, strong) NSDictionary *objectMapping;
|
@property (nonatomic, strong, getter=getObject) NSDictionary *objectMapping;
|
||||||
|
|
||||||
- (instancetype) initWithJSON:(NSDictionary*) JSON;
|
- (instancetype) initWithJSON:(NSDictionary*) JSON;
|
||||||
|
|
||||||
|
+ (void) get;
|
||||||
@end
|
@end
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
#import <PNObjectProperty.h>
|
#import <PNObjectProperty.h>
|
||||||
#import <NSDate_Utils/NSDate+NSDate_Util.h>
|
#import <NSDate_Utils/NSDate+NSDate_Util.h>
|
||||||
#import <AFNetworking/AFNetworking.h>
|
#import <AFNetworking/AFNetworking.h>
|
||||||
#import "User/PNUser.h"
|
#import "PNObject/PNUser.h"
|
||||||
|
|
||||||
@interface PNObject()
|
@interface PNObject()
|
||||||
|
|
||||||
@ -22,6 +22,32 @@
|
|||||||
|
|
||||||
@implementation PNObject
|
@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 {
|
- (instancetype) init {
|
||||||
self = [super init];
|
self = [super init];
|
||||||
|
|
||||||
@ -123,7 +149,7 @@
|
|||||||
else {
|
else {
|
||||||
BOOL isPNObjectSubclass = [NSClassFromString(propertyType) isSubclassOfClass:[PNObject class]];
|
BOOL isPNObjectSubclass = [NSClassFromString(propertyType) isSubclassOfClass:[PNObject class]];
|
||||||
if(isPNObjectSubclass) {
|
if(isPNObjectSubclass) {
|
||||||
SEL selector = NSSelectorFromString(@"reverseMapping");
|
SEL selector = NSSelectorFromString(@"getObject");
|
||||||
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:
|
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:
|
||||||
[[PNObject class] instanceMethodSignatureForSelector:selector]];
|
[[PNObject class] instanceMethodSignatureForSelector:selector]];
|
||||||
[invocation setSelector:selector];
|
[invocation setSelector:selector];
|
||||||
@ -149,6 +175,10 @@
|
|||||||
return _JSON;
|
return _JSON;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSDictionary*) getObject {
|
||||||
|
return [self reverseMapping];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)populateObjectFromJSON:(id)JSON
|
- (void)populateObjectFromJSON:(id)JSON
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import <PNObject/PNObject.h>
|
#import <PNObject/PNObject.h>
|
||||||
#import "PNLocation.h"
|
#import <PNObject/PNLocation.h>
|
||||||
|
|
||||||
@interface PNAddress : PNObject <PNObjectSubclassing>
|
@interface PNAddress : PNObject <PNObjectSubclassing>
|
||||||
|
|
||||||
|
|||||||
@ -2,33 +2,18 @@
|
|||||||
// PNUser.h
|
// PNUser.h
|
||||||
// Pods
|
// Pods
|
||||||
//
|
//
|
||||||
// Created by Giuseppe Nucifora on 08/01/16.
|
// Created by Giuseppe Nucifora on 15/01/16.
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
|
||||||
#import <PNObject/PNObject.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import "PNAddress.h"
|
|
||||||
|
|
||||||
@interface PNUser : PNObject <PNObjectSubclassing>
|
@interface PNUser : NSObject
|
||||||
|
|
||||||
@property (strong, nonatomic) NSString *userId;
|
/**
|
||||||
@property (strong, nonatomic) NSString *firstName;
|
* gets singleton object.
|
||||||
@property (strong, nonatomic) NSString *lastName;
|
* @return singleton
|
||||||
@property (nonatomic, strong) NSString *profileImage;
|
*/
|
||||||
@property (nonatomic, strong) NSString *sex;
|
+ (PNUser*)sharedInstance;
|
||||||
@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;
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
// PNUser.m
|
// PNUser.m
|
||||||
// Pods
|
// Pods
|
||||||
//
|
//
|
||||||
// Created by Giuseppe Nucifora on 08/01/16.
|
// Created by Giuseppe Nucifora on 15/01/16.
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
|
||||||
@ -10,54 +10,60 @@
|
|||||||
|
|
||||||
@implementation PNUser
|
@implementation PNUser
|
||||||
|
|
||||||
/*
|
static PNUser *SINGLETON = nil;
|
||||||
@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;
|
|
||||||
*/
|
|
||||||
|
|
||||||
+ (NSDictionary *)objcetMapping {
|
static bool isFirstAccess = YES;
|
||||||
NSDictionary *mapping = @{@"userId":@"id",
|
|
||||||
@"firstName":@"firstName",
|
#pragma mark - Public Method
|
||||||
@"lastName":@"lastName",
|
|
||||||
@"profileImage":@"profileImage",
|
+ (id)sharedInstance
|
||||||
@"sex":@"sex",
|
{
|
||||||
@"birthDate":@"birthDate",
|
static dispatch_once_t onceToken;
|
||||||
@"phone":@"phone",
|
dispatch_once(&onceToken, ^{
|
||||||
@"hasAcceptedPrivacy":@"hasAcceptedPrivacy",
|
isFirstAccess = NO;
|
||||||
@"hasAcceptedNewsletter":@"hasAcceptedNewsletter",
|
SINGLETON = [[super allocWithZone:NULL] init];
|
||||||
@"hasVerifiedEmail":@"hasVerifiedEmail",
|
});
|
||||||
@"emailVerifiedDate":@"emailVerifiedDate",
|
|
||||||
@"email":@"email",
|
return SINGLETON;
|
||||||
@"username":@"username",
|
|
||||||
@"publicProfile":@"public_profile",
|
|
||||||
@"loginCount":@"login_count",
|
|
||||||
@"createdAt":@"created_at",
|
|
||||||
@"facebookId":@"facebookId",
|
|
||||||
@"facebookAccessToken":@"facebookAccessToken",
|
|
||||||
@"address":@{@"key":@"address",@"type":@"PNAddress"}
|
|
||||||
};
|
|
||||||
return mapping;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSString *)objectClassName {
|
#pragma mark - Life Cycle
|
||||||
return @"User";
|
|
||||||
|
+ (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