- Fix vari

This commit is contained in:
giuseppenuc committed 2016-01-13 11:24:05 +01:00
1 parent c3e77e7a09
commit e2e17186ac
30 files changed
+1254 -873

No files matched your search

+38 -15
View File
@@ -10,6 +10,7 @@
#import <PNObjectProperty.h>
#import <NSDate_Utils/NSDate+NSDate_Util.h>
#import <AFNetworking/AFNetworking.h>
#import "User/PNUser.h"
@interface PNObject()
@@ -21,12 +22,43 @@
@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];
if (self) {
if ([[self class] isSubclassOfClass:[PNObject class]]) {
NSAssert([[self class] conformsToProtocol:@protocol(PNObjectSubclassing)], @"Subclass object must conform to PNObjectSubclassing");
_objectMapping = [[self class] objcetMapping];
NSAssert(_objectMapping, @"You must create objectMapping");
}
}
return self;
}
@@ -34,6 +66,7 @@
- (instancetype) initWithJSON:(NSDictionary*) JSON {
self = [self init];
if (self) {
NSAssert(_objectMapping, @"You must create objectMapping");
_JSON = [[NSDictionary alloc] initWithDictionary:JSON];
@@ -179,8 +212,6 @@
continue;
}
//NSLog(@"Looking for : %@ -- %@ -- %@", propertyType, mappedJSONKey, value);
((void (^)())@{
@"c" : ^{
@@ -217,7 +248,7 @@
},
@"NSDate" : ^{
NSString *str = [NSString stringWithFormat:@"%@", value];
NSDate *val = [NSDate dateFromString:str];
NSDate *val = [[NSDate dateFromString:str withFormat:kNSDateHelperFormatSQLDateWithTime] toLocalTime];
[self setValue:val forKey:propertyName];
},
@"NSArray" : ^{
@@ -253,16 +284,8 @@
}
#pragma mark PNObjectSubclassing
+ (NSString *) objectClassName {
- (NSString*) description {
return [_JSON description];
}
+ (NSDictionary *) objcetMapping {
}
#pragma mark -
@end