From f25ede069d194cbe013978eec108d1915044a39f Mon Sep 17 00:00:00 2001 From: Giuseppe Nucifora Date: Fri, 15 Jan 2016 19:22:34 +0100 Subject: [PATCH] - Fix --- Example/PNObject/PNObjectAppDelegate.m | 12 +++--- Example/Pods/Pods.xcodeproj/project.pbxproj | 6 +++ Pod/Classes/User/PNAddress.h | 4 +- Pod/Classes/User/PNLocation.h | 2 +- Pod/Classes/User/PNUser.h | 36 +++++++++++++++-- Pod/Classes/User/PNUser.m | 45 ++++++++++++++++++--- 6 files changed, 87 insertions(+), 18 deletions(-) diff --git a/Example/PNObject/PNObjectAppDelegate.m b/Example/PNObject/PNObjectAppDelegate.m index ea30551..7d6dd19 100644 --- a/Example/PNObject/PNObjectAppDelegate.m +++ b/Example/PNObject/PNObjectAppDelegate.m @@ -25,12 +25,12 @@ [PNObject get];*/ - /*PNUser *user = [PNUser sharedInstance]; - [user setFirstName:@"peppe"]; - [user setLastName:@"nucifora"]; - - NSLog(@"user : %@",[user getObject]); - */ + PNUser *user = [PNUser sharedInstance]; + [user setFirstName:@"peppe"]; + [user setLastName:@"nucifora"]; + + NSLog(@"user : %@",[user getObject]); + return YES; } diff --git a/Example/Pods/Pods.xcodeproj/project.pbxproj b/Example/Pods/Pods.xcodeproj/project.pbxproj index ffbd115..fe21677 100644 --- a/Example/Pods/Pods.xcodeproj/project.pbxproj +++ b/Example/Pods/Pods.xcodeproj/project.pbxproj @@ -105,6 +105,9 @@ 66A27898E989A3FA5C15AA671C4536F0 /* EXPMatchers+beIdenticalTo.m in Sources */ = {isa = PBXBuildFile; fileRef = ABC2BD19C88FB68928A4ACDD68A9A724 /* EXPMatchers+beIdenticalTo.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; 67459AD239EF669A365519E06B45DCFE /* EXPExpect.h in Headers */ = {isa = PBXBuildFile; fileRef = A9C30C86ADD90253F9625EE97E677992 /* EXPExpect.h */; settings = {ATTRIBUTES = (Public, ); }; }; 68152D921ABF6A423C192C04FDF94F0F /* AFNetworkReachabilityManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 6D147D9B92257C3B94B576C35DC424BF /* AFNetworkReachabilityManager.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 6846FE011C496CB400FD46A7 /* NSDate_Utils.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6BCF0B57CC5FE7DB7261CE7C60EAE6C1 /* NSDate_Utils.framework */; }; + 6846FE021C496CB400FD46A7 /* PEAR_FileManager_iOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 27053B717A2E6C890A9A5567BE892759 /* PEAR_FileManager_iOS.framework */; }; + 6846FE031C496CB400FD46A7 /* UIDevice_Utils.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CB327A2C4264D8D750739600AF58AB3C /* UIDevice_Utils.framework */; }; 68A38977EBAE334DC3C22386D00D2622 /* AFNetworkReachabilityManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 01C0656AD6CD15FA1E1CD0B12E72DBAC /* AFNetworkReachabilityManager.m */; }; 6E1D978790705E137FDE439AA68DD3AA /* EXPFloatTuple.h in Headers */ = {isa = PBXBuildFile; fileRef = 61F3C1DB6F4E00473063EACFC5515CC3 /* EXPFloatTuple.h */; settings = {ATTRIBUTES = (Public, ); }; }; 6EBB812C79C5E73FF5263EAB649CEEBC /* SPTTestSuite.m in Sources */ = {isa = PBXBuildFile; fileRef = DE7319124E858F652E78EEE78BFCD99A /* SPTTestSuite.m */; }; @@ -639,6 +642,9 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 6846FE011C496CB400FD46A7 /* NSDate_Utils.framework in Frameworks */, + 6846FE021C496CB400FD46A7 /* PEAR_FileManager_iOS.framework in Frameworks */, + 6846FE031C496CB400FD46A7 /* UIDevice_Utils.framework in Frameworks */, 16A9A6CCC4F249BFD94D85BEE83DCF72 /* AFNetworking.framework in Frameworks */, CE254752A8C232EBE37D84810F7724E5 /* Foundation.framework in Frameworks */, ); diff --git a/Pod/Classes/User/PNAddress.h b/Pod/Classes/User/PNAddress.h index b89c742..3f2ebef 100644 --- a/Pod/Classes/User/PNAddress.h +++ b/Pod/Classes/User/PNAddress.h @@ -6,8 +6,8 @@ // // -#import -#import +#import "PNObject.h" +#import "PNLocation.h" @interface PNAddress : PNObject diff --git a/Pod/Classes/User/PNLocation.h b/Pod/Classes/User/PNLocation.h index 84de273..7800337 100644 --- a/Pod/Classes/User/PNLocation.h +++ b/Pod/Classes/User/PNLocation.h @@ -6,7 +6,7 @@ // // -#import +#import "PNObject.h" @interface PNLocation : PNObject diff --git a/Pod/Classes/User/PNUser.h b/Pod/Classes/User/PNUser.h index 050a16f..d666b45 100644 --- a/Pod/Classes/User/PNUser.h +++ b/Pod/Classes/User/PNUser.h @@ -6,14 +6,44 @@ // // -#import +#import "PNObject.h" +#import "PNAddress.h" -@interface PNUser : NSObject +@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 (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; ++ (instancetype)sharedInstance; + + +/** + * gets singleton object of current user session. + * + * @return singleton + */ ++ (instancetype) currentUser; @end diff --git a/Pod/Classes/User/PNUser.m b/Pod/Classes/User/PNUser.m index 990e847..ef18007 100644 --- a/Pod/Classes/User/PNUser.m +++ b/Pod/Classes/User/PNUser.m @@ -16,7 +16,7 @@ static bool isFirstAccess = YES; #pragma mark - Public Method -+ (id)sharedInstance ++ (instancetype)sharedInstance { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ @@ -27,29 +27,33 @@ static bool isFirstAccess = YES; return SINGLETON; } ++ (instancetype) currentUser { + return [self sharedInstance]; +} + #pragma mark - Life Cycle -+ (id) allocWithZone:(NSZone *)zone ++ (instancetype) allocWithZone:(NSZone *)zone { return [self sharedInstance]; } -+ (id)copyWithZone:(struct _NSZone *)zone ++ (instancetype)copyWithZone:(struct _NSZone *)zone { return [self sharedInstance]; } -+ (id)mutableCopyWithZone:(struct _NSZone *)zone ++ (instancetype)mutableCopyWithZone:(struct _NSZone *)zone { return [self sharedInstance]; } -- (id)copy +- (instancetype)copy { return [[PNUser alloc] init]; } -- (id)mutableCopy +- (instancetype)mutableCopy { return [[PNUser alloc] init]; } @@ -66,5 +70,34 @@ static bool isFirstAccess = YES; return self; } ++ (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; +} + ++ (NSString *)objectClassName { + return @"User"; +} + + @end