- Fix vari
This commit is contained in:
parent
07ae0d3b42
commit
41c856b3c9
@ -71,7 +71,44 @@
|
||||
ReferencedContainer = "container:PNObject.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
<EnvironmentVariables>
|
||||
<EnvironmentVariable
|
||||
key = "NSZombieEnabled"
|
||||
value = "YES"
|
||||
isEnabled = "YES">
|
||||
</EnvironmentVariable>
|
||||
<EnvironmentVariable
|
||||
key = "NSAutoreleaseFreedObjectCheckEnabled"
|
||||
value = "YES"
|
||||
isEnabled = "YES">
|
||||
</EnvironmentVariable>
|
||||
<EnvironmentVariable
|
||||
key = "NSDebugEnabled"
|
||||
value = "YES"
|
||||
isEnabled = "YES">
|
||||
</EnvironmentVariable>
|
||||
</EnvironmentVariables>
|
||||
<AdditionalOptions>
|
||||
<AdditionalOption
|
||||
key = "DYLD_INSERT_LIBRARIES"
|
||||
value = "/usr/lib/libgmalloc.dylib"
|
||||
isEnabled = "YES">
|
||||
</AdditionalOption>
|
||||
<AdditionalOption
|
||||
key = "NSZombieEnabled"
|
||||
value = "YES"
|
||||
isEnabled = "YES">
|
||||
</AdditionalOption>
|
||||
<AdditionalOption
|
||||
key = "MallocGuardEdges"
|
||||
value = ""
|
||||
isEnabled = "YES">
|
||||
</AdditionalOption>
|
||||
<AdditionalOption
|
||||
key = "MallocScribble"
|
||||
value = ""
|
||||
isEnabled = "YES">
|
||||
</AdditionalOption>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
|
||||
@ -18,40 +18,55 @@
|
||||
// Override point for customization after application launch.
|
||||
[PNObjectConfig initSharedInstanceForEnvironments:@{ EnvironmentDevelopment : @"https://development.it/api/v1",
|
||||
EnvironmentStage : @"https://stage.it/api/v1",
|
||||
EnvironmentProduction : @"http://pnobjectdemo.giuseppenucifora.com/"
|
||||
EnvironmentProduction : @"https://pnobject.giuseppenucifora.com/"
|
||||
}];
|
||||
|
||||
[[PNObjectConfig sharedInstance] setEnvironment:Production];
|
||||
[[[PNObjectConfig sharedInstance] manager] setSecurityPolicy:[AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeCertificate]];
|
||||
[[PNObjectConfig sharedInstance] manager].securityPolicy.allowInvalidCertificates = YES;
|
||||
//[[[PNObjectConfig sharedInstance] manager] setSecurityPolicy:[AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeCertificate]];
|
||||
//[[PNObjectConfig sharedInstance] manager].securityPolicy.allowInvalidCertificates = YES;
|
||||
|
||||
//[PNObject get];*/
|
||||
|
||||
PNUser *user = [PNUser currentUser];
|
||||
|
||||
//NSLog(@"user : %@",[user getJSONObject]);
|
||||
|
||||
//[user autoRemoveLocally];
|
||||
[user setFirstName:@"Giuseppe2"];
|
||||
[user setLastName:@"Nucifora2"];
|
||||
[user setEmail:@"giuseppe.nucifora@giuseppenucifora.com"];
|
||||
[user setSex:@"M"];
|
||||
[user setHasAcceptedNewsletter:NO];
|
||||
[user setHasAcceptedPrivacy:YES];
|
||||
[user setUsername:@"giuseppe.nucifora"];
|
||||
[user setPassword:@"giuseppe.nucifora.password"];
|
||||
[user setPhone:@"+393485904995"];
|
||||
[user setUserId:@"blablabla"];
|
||||
[user saveLocally];
|
||||
/*
|
||||
PNUser *user = [PNUser currentUser];
|
||||
|
||||
//NSLog(@"user : %@",[user getJSONObject]);
|
||||
|
||||
//[user autoRemoveLocally];
|
||||
[user setFirstName:@"Giuseppe2"];
|
||||
[user setLastName:@"Nucifora2"];
|
||||
[user setEmail:@"giuseppe.nucifora@giuseppenucifora.com"];
|
||||
[user setSex:@"M"];
|
||||
[user setHasAcceptedNewsletter:NO];
|
||||
[user setHasAcceptedPrivacy:YES];
|
||||
[user setUsername:@"giuseppe.nucifora"];
|
||||
[user setPassword:@"giuseppe.nucifora.password"];
|
||||
[user setPhone:@"+393485904995"];
|
||||
[user setUserId:@"blablabla"];
|
||||
[user saveLocally];
|
||||
|
||||
|
||||
|
||||
[user setFirstName:@"Angela"];
|
||||
[user setLastName:@"Sapienza"];
|
||||
|
||||
[user getJSONObject];*/
|
||||
|
||||
|
||||
|
||||
[user setFirstName:@"Angela"];
|
||||
[user setLastName:@"Sapienza"];
|
||||
|
||||
[user getJSONObject];
|
||||
|
||||
NSLog(@"%@",[PNUser PNObjClassName]);
|
||||
[[[PNObjectConfig sharedInstance] manager] GET:[[[PNObjectConfig sharedInstance] PNObjEndpoint] stringByAppendingString:[PNAccessToken PNObjClassName]] parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {
|
||||
|
||||
} success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
|
||||
|
||||
PNAccessToken *accessToken = [[PNAccessToken alloc] initWithJSON:responseObject];
|
||||
|
||||
NSLog(@"%@",[accessToken getJSONObject]);
|
||||
[accessToken saveLocally];
|
||||
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
|
||||
NSLog(@"%@",error);
|
||||
|
||||
}];
|
||||
//NSLog(@"%@",userDictionary);
|
||||
|
||||
/*
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
@autoreleasepool {
|
||||
return UIApplicationMain(argc, argv, nil, NSStringFromClass([PNObjectAppDelegate class]));
|
||||
}
|
||||
@autoreleasepool {
|
||||
return UIApplicationMain(argc, argv, nil, NSStringFromClass([PNObjectAppDelegate class]));
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ PODS:
|
||||
- NSString-Helper (1.0.2)
|
||||
- nv-ios-http-status (0.0.1)
|
||||
- PEAR-FileManager-iOS (1.3.1)
|
||||
- PNObject (0.1.0):
|
||||
- PNObject (0.2.3):
|
||||
- AFNetworking
|
||||
- CodFis-Helper
|
||||
- NSDate_Utils
|
||||
@ -69,7 +69,7 @@ SPEC CHECKSUMS:
|
||||
NSString-Helper: 0ee74919829a332f9838fa87b28cb2d1d991e92c
|
||||
nv-ios-http-status: b6c2b5fc8656cc19e0d3000dadce2080b99d0e2f
|
||||
PEAR-FileManager-iOS: 3bc403f68a53483f5629aa822f4649e40275c4d3
|
||||
PNObject: b71ba455c15aedd1233cdf02bcf65d348d96da72
|
||||
PNObject: 7bd9bb008740ecb0d8e5a8ab58606a4eb4d10132
|
||||
Specta: ac94d110b865115fe60ff2c6d7281053c6f8e8a2
|
||||
StrongestPasswordValidator: 554de9038705e18904f0337903dfd3b85a6b271b
|
||||
UIDevice-Utils: 0beb5f9d2bd256a3efe05c1e43a2a8b8702199c4
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "PNObject",
|
||||
"version": "0.1.0",
|
||||
"summary": "PNObject.",
|
||||
"version": "0.2.3",
|
||||
"summary": "PNObject is a simple replica of the more complex ParseObject",
|
||||
"homepage": "https://github.com/giuseppenucifora/PNObject",
|
||||
"license": "MIT",
|
||||
"authors": {
|
||||
@ -9,7 +9,7 @@
|
||||
},
|
||||
"source": {
|
||||
"git": "https://github.com/giuseppenucifora/PNObject.git",
|
||||
"tag": "0.1.0"
|
||||
"tag": "0.2.3"
|
||||
},
|
||||
"platforms": {
|
||||
"ios": "7.0"
|
||||
|
||||
4
Example/Pods/Manifest.lock
generated
4
Example/Pods/Manifest.lock
generated
@ -28,7 +28,7 @@ PODS:
|
||||
- NSString-Helper (1.0.2)
|
||||
- nv-ios-http-status (0.0.1)
|
||||
- PEAR-FileManager-iOS (1.3.1)
|
||||
- PNObject (0.1.0):
|
||||
- PNObject (0.2.3):
|
||||
- AFNetworking
|
||||
- CodFis-Helper
|
||||
- NSDate_Utils
|
||||
@ -69,7 +69,7 @@ SPEC CHECKSUMS:
|
||||
NSString-Helper: 0ee74919829a332f9838fa87b28cb2d1d991e92c
|
||||
nv-ios-http-status: b6c2b5fc8656cc19e0d3000dadce2080b99d0e2f
|
||||
PEAR-FileManager-iOS: 3bc403f68a53483f5629aa822f4649e40275c4d3
|
||||
PNObject: b71ba455c15aedd1233cdf02bcf65d348d96da72
|
||||
PNObject: 7bd9bb008740ecb0d8e5a8ab58606a4eb4d10132
|
||||
Specta: ac94d110b865115fe60ff2c6d7281053c6f8e8a2
|
||||
StrongestPasswordValidator: 554de9038705e18904f0337903dfd3b85a6b271b
|
||||
UIDevice-Utils: 0beb5f9d2bd256a3efe05c1e43a2a8b8702199c4
|
||||
|
||||
1052
Example/Pods/Pods.xcodeproj/project.pbxproj
generated
1052
Example/Pods/Pods.xcodeproj/project.pbxproj
generated
File diff suppressed because it is too large
Load Diff
@ -14,7 +14,7 @@
|
||||
buildForArchiving = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = 'primary'
|
||||
BlueprintIdentifier = '4FB4437C636DCECA1396EC4C'
|
||||
BlueprintIdentifier = 'E35BB1A0261F32B3489855CF'
|
||||
BlueprintName = 'PNObject'
|
||||
ReferencedContainer = 'container:Pods.xcodeproj'
|
||||
BuildableName = 'PNObject.framework'>
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>0.1.0</string>
|
||||
<string>0.2.3</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
|
||||
@ -1,15 +1,16 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import "PNAccessToken.h"
|
||||
#import "PNAddress.h"
|
||||
#import "PNInstallation.h"
|
||||
#import "PNLocation.h"
|
||||
#import "PNUser.h"
|
||||
#import "PNObject+PNObjectConnection.h"
|
||||
#import "PNObject+Protected.h"
|
||||
#import "PNObject.h"
|
||||
#import "PNObjectConfig.h"
|
||||
#import "PNObjectConstants.h"
|
||||
#import "PNObjectModel.h"
|
||||
#import "PNObjectProperty.h"
|
||||
#import "PNAddress.h"
|
||||
#import "PNLocation.h"
|
||||
#import "PNUser.h"
|
||||
|
||||
FOUNDATION_EXPORT double PNObjectVersionNumber;
|
||||
FOUNDATION_EXPORT const unsigned char PNObjectVersionString[];
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>BNDL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>0.1.0</string>
|
||||
<string>0.2.3</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "PNObject"
|
||||
s.version = "0.2.3"
|
||||
s.version = "0.2.4"
|
||||
s.summary = "PNObject is a simple replica of the more complex ParseObject"
|
||||
|
||||
# This description is used to generate tags and improve search results.
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
//
|
||||
//
|
||||
|
||||
#import <PNObject/PNObject.h>
|
||||
#import "PNObject.h"
|
||||
|
||||
@interface PNAccessToken : PNObject
|
||||
|
||||
@ -14,6 +14,20 @@ typedef NS_ENUM(NSInteger, TokenType) {
|
||||
TokenTypeBasic = 1,
|
||||
TokenTypeBearer = 2
|
||||
};
|
||||
|
||||
/**
|
||||
* gets singleton object of current user session.
|
||||
*
|
||||
* @return singleton
|
||||
*/
|
||||
+ (instancetype _Nonnull) currentUser;
|
||||
|
||||
|
||||
///--------------------------------------
|
||||
#pragma mark - PNAccessToken Properties
|
||||
///--------------------------------------
|
||||
|
||||
|
||||
/**
|
||||
* <#Description#>
|
||||
*/
|
||||
@ -22,9 +36,18 @@ typedef NS_ENUM(NSInteger, TokenType) {
|
||||
* <#Description#>
|
||||
*/
|
||||
@property (nonatomic, strong, nullable) NSDate *expirationDate;
|
||||
|
||||
@property (nonatomic, strong, nullable) NSNumber *expiresIn;
|
||||
/**
|
||||
* <#Description#>
|
||||
*/
|
||||
@property (nonatomic) TokenType tokenType;
|
||||
|
||||
@property (nonatomic, strong, nullable) NSString *tokenTypeString;
|
||||
|
||||
@property (nonatomic, strong, nullable) NSString *scope;
|
||||
|
||||
@property (nonatomic, strong, nullable) NSString *refreshToken;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
#import "PNAccessToken.h"
|
||||
#import <NSDate_Utils/NSDate+NSDate_Util.h>
|
||||
|
||||
@interface PNAccessToken() <PNObjectSubclassing>
|
||||
|
||||
@ -19,13 +20,35 @@
|
||||
+ (NSDictionary *)objcetMapping {
|
||||
|
||||
NSDictionary *mapping = @{
|
||||
@"accessToken":@"accessToken",
|
||||
@"expirationDate":@"expirationDate",
|
||||
@"tokenType":@"tokenType",
|
||||
@"accessToken":@"access_token",
|
||||
@"expiresIn":@"expires_in",
|
||||
@"tokenTypeString":@"token_type",
|
||||
@"tokenType":@"scope",
|
||||
@"refreshToken":@"refresh_token",
|
||||
};
|
||||
return mapping;
|
||||
}
|
||||
|
||||
- (instancetype) initWithJSON:(NSDictionary *)JSON {
|
||||
self = [super initWithJSON:JSON];
|
||||
|
||||
if (self) {
|
||||
((void (^)())@{
|
||||
@"beaer" : ^{
|
||||
_tokenType = TokenTypeBearer;
|
||||
},
|
||||
@"basic" : ^{
|
||||
_tokenType = TokenTypeBasic;
|
||||
}
|
||||
}[_tokenTypeString] ?: ^{
|
||||
|
||||
})();
|
||||
|
||||
_expirationDate = [[NSDate date] dateByAddingHours:[_expiresIn integerValue]];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (NSString *)objectClassName {
|
||||
return @"AccessToken";
|
||||
}
|
||||
@ -38,7 +61,4 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
//
|
||||
|
||||
#import "PNObject.h"
|
||||
|
||||
#import "PNAccessToken.h"
|
||||
|
||||
@interface PNUser : PNObject
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
//- (void) setPassword:(NSString * _Nonnull)password inBackGroundWithBlock:(nullable void (^)(BOOL saveStatus, id responseObject, NSError * error)) responseBlock;
|
||||
|
||||
///--------------------------------------
|
||||
#pragma mark - PNLocation Properties
|
||||
#pragma mark - PNUser Properties
|
||||
///--------------------------------------
|
||||
|
||||
/**
|
||||
|
||||
@ -27,6 +27,9 @@
|
||||
NSDictionary *properties = [PNObject propertiesForClass:self.class];
|
||||
|
||||
for (NSString *propertyName in properties) {
|
||||
if ([propertyName isEqualToString:@"description"] || [propertyName isEqualToString:@"debugDescription"]) {
|
||||
continue;
|
||||
}
|
||||
[self addObserver:self forKeyPath:propertyName options:NSKeyValueObservingOptionNew context:nil];
|
||||
}
|
||||
|
||||
@ -39,8 +42,11 @@
|
||||
NSString *mappedJSONType;
|
||||
|
||||
NSString *propertyType = [properties valueForKey:propertyName];
|
||||
NSLogDebug(@"%@",self.objectMapping);
|
||||
|
||||
id mappingValue = [self.objectMapping valueForKey:propertyName];
|
||||
NSLogDebug(@"%@",[[self class] objcetMapping]);
|
||||
|
||||
id mappingValue = [[[self class] objcetMapping] valueForKey:propertyName];
|
||||
|
||||
if([mappingValue isKindOfClass:NSDictionary.class]) {
|
||||
mappedJSONKey = [mappingValue valueForKey:@"key"];
|
||||
@ -55,7 +61,7 @@
|
||||
}
|
||||
|
||||
// Get JSON value for the mapped key
|
||||
id value = [JSON valueForKeyPath:propertyName];
|
||||
id value = [JSON valueForKeyPath:mappedJSONKey];
|
||||
|
||||
|
||||
((void (^)())@{
|
||||
|
||||
@ -259,6 +259,7 @@
|
||||
return _JSON;
|
||||
}
|
||||
|
||||
|
||||
- (NSDictionary* _Nonnull) getJSONObject {
|
||||
if (!_JSON) {
|
||||
return [self reverseMapping];
|
||||
@ -307,7 +308,9 @@
|
||||
|
||||
- (id _Nonnull) saveLocally {
|
||||
|
||||
return [_objectModel saveLocally:self];
|
||||
__weak id weakSelf = self;
|
||||
|
||||
return [_objectModel saveLocally:weakSelf];
|
||||
}
|
||||
|
||||
- (BOOL) autoRemoveLocally {
|
||||
@ -318,20 +321,26 @@
|
||||
|
||||
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
|
||||
{
|
||||
[_JSON setObject:[change objectForKey:@"new"] forKey:keyPath];
|
||||
NSLogDebug(@"%@",[[[self class] objcetMapping] objectForKey:keyPath]);
|
||||
[_JSON setObject:[change objectForKey:@"new"] forKey:[[[self class] objcetMapping] objectForKey:keyPath]];
|
||||
}
|
||||
|
||||
/*- (void)dealloc
|
||||
{
|
||||
- (void)dealloc
|
||||
{
|
||||
NSDictionary *properties = [PNObject propertiesForClass:self.class];
|
||||
|
||||
for (NSString *propertyName in properties) {
|
||||
if ([[PNObject protectedProperties] containsObject:propertyName]) {
|
||||
continue;
|
||||
}
|
||||
[self removeObserver:self forKeyPath:propertyName];
|
||||
if ([propertyName isEqualToString:@"description"] || [propertyName isEqualToString:@"debugDescription"]) {
|
||||
continue;
|
||||
}
|
||||
[self removeObserver:self forKeyPath:propertyName];
|
||||
}
|
||||
}
|
||||
*/
|
||||
_JSON = nil;
|
||||
_objectMapping = nil;
|
||||
_objID = nil;
|
||||
_createdAt = nil;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@ -39,134 +39,136 @@ static bool isFirstAccess = YES;
|
||||
|
||||
+ (instancetype)sharedInstance
|
||||
{
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
isFirstAccess = NO;
|
||||
SINGLETON = [[super allocWithZone:NULL] init];
|
||||
});
|
||||
|
||||
return SINGLETON;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
isFirstAccess = NO;
|
||||
SINGLETON = [[super allocWithZone:NULL] init];
|
||||
});
|
||||
|
||||
return SINGLETON;
|
||||
}
|
||||
|
||||
#pragma mark - Life Cycle
|
||||
|
||||
+ (instancetype) initSharedInstanceForEnvironments:(NSDictionary *) endpointUrlsForEnvironments {
|
||||
SINGLETON = [self sharedInstance];
|
||||
|
||||
if (SINGLETON) {
|
||||
for (NSString *key in [endpointUrlsForEnvironments allKeys]) {
|
||||
|
||||
((void (^)())@{
|
||||
EnvironmentDevelopment : ^{
|
||||
NSURL * endpointUrl = [NSURL URLWithString:[endpointUrlsForEnvironments objectForKey:key]];
|
||||
if (endpointUrl) {
|
||||
[SINGLETON.configuration setValue:[endpointUrl absoluteString] forKey:key];
|
||||
SINGLETON.devEnabled = YES;
|
||||
}
|
||||
|
||||
},
|
||||
EnvironmentStage : ^{
|
||||
NSURL * endpointUrl = [NSURL URLWithString:[endpointUrlsForEnvironments objectForKey:key]];
|
||||
if (endpointUrl) {
|
||||
[SINGLETON.configuration setValue:[endpointUrl absoluteString] forKey:key];
|
||||
SINGLETON.stageEnabled = YES;
|
||||
}
|
||||
},
|
||||
EnvironmentProduction : ^{
|
||||
NSURL * endpointUrl = [NSURL URLWithString:[endpointUrlsForEnvironments objectForKey:key]];
|
||||
if (endpointUrl) {
|
||||
[SINGLETON.configuration setValue:[endpointUrl absoluteString] forKey:key];
|
||||
SINGLETON.productionEnabled = YES;
|
||||
}
|
||||
}
|
||||
}[key] ?: ^{
|
||||
|
||||
})();
|
||||
}
|
||||
NSAssert(SINGLETON.productionEnabled, @"EnvironmentProduction must be valid endpoint url");
|
||||
SINGLETON.currentEnvironment = [[SINGLETON configuration] objectForKey:EnvironmentProduction];
|
||||
|
||||
}
|
||||
return SINGLETON;
|
||||
SINGLETON = [self sharedInstance];
|
||||
|
||||
if (SINGLETON) {
|
||||
for (NSString *key in [endpointUrlsForEnvironments allKeys]) {
|
||||
|
||||
((void (^)())@{
|
||||
EnvironmentDevelopment : ^{
|
||||
NSURL * endpointUrl = [NSURL URLWithString:[endpointUrlsForEnvironments objectForKey:key]];
|
||||
if (endpointUrl) {
|
||||
[SINGLETON.configuration setValue:[endpointUrl absoluteString] forKey:key];
|
||||
SINGLETON.devEnabled = YES;
|
||||
}
|
||||
|
||||
},
|
||||
EnvironmentStage : ^{
|
||||
NSURL * endpointUrl = [NSURL URLWithString:[endpointUrlsForEnvironments objectForKey:key]];
|
||||
if (endpointUrl) {
|
||||
[SINGLETON.configuration setValue:[endpointUrl absoluteString] forKey:key];
|
||||
SINGLETON.stageEnabled = YES;
|
||||
}
|
||||
},
|
||||
EnvironmentProduction : ^{
|
||||
NSURL * endpointUrl = [NSURL URLWithString:[endpointUrlsForEnvironments objectForKey:key]];
|
||||
if (endpointUrl) {
|
||||
[SINGLETON.configuration setValue:[endpointUrl absoluteString] forKey:key];
|
||||
SINGLETON.productionEnabled = YES;
|
||||
}
|
||||
}
|
||||
}[key] ?: ^{
|
||||
|
||||
})();
|
||||
}
|
||||
NSAssert(SINGLETON.productionEnabled, @"EnvironmentProduction must be valid endpoint url");
|
||||
SINGLETON.currentEnvironment = [[SINGLETON configuration] objectForKey:EnvironmentProduction];
|
||||
|
||||
}
|
||||
return SINGLETON;
|
||||
}
|
||||
|
||||
+ (id) allocWithZone:(NSZone *)zone
|
||||
{
|
||||
return [self sharedInstance];
|
||||
return [self sharedInstance];
|
||||
}
|
||||
|
||||
+ (id)copyWithZone:(struct _NSZone *)zone
|
||||
{
|
||||
return [self sharedInstance];
|
||||
return [self sharedInstance];
|
||||
}
|
||||
|
||||
+ (id)mutableCopyWithZone:(struct _NSZone *)zone
|
||||
{
|
||||
return [self sharedInstance];
|
||||
return [self sharedInstance];
|
||||
}
|
||||
|
||||
- (id)copy
|
||||
{
|
||||
return [[PNObjectConfig alloc] init];
|
||||
return [[PNObjectConfig alloc] init];
|
||||
}
|
||||
|
||||
- (id)mutableCopy
|
||||
{
|
||||
return [[PNObjectConfig alloc] init];
|
||||
return [[PNObjectConfig alloc] init];
|
||||
}
|
||||
|
||||
- (id) init
|
||||
{
|
||||
if(SINGLETON){
|
||||
return SINGLETON;
|
||||
}
|
||||
if (isFirstAccess) {
|
||||
[self doesNotRecognizeSelector:_cmd];
|
||||
}
|
||||
self = [super init];
|
||||
|
||||
if (self) {
|
||||
_configuration = [[NSMutableDictionary alloc] init];
|
||||
_minPasswordLenght = minPassLenght;
|
||||
}
|
||||
return self;
|
||||
if(SINGLETON){
|
||||
return SINGLETON;
|
||||
}
|
||||
if (isFirstAccess) {
|
||||
[self doesNotRecognizeSelector:_cmd];
|
||||
}
|
||||
self = [super init];
|
||||
|
||||
if (self) {
|
||||
_configuration = [[NSMutableDictionary alloc] init];
|
||||
_minPasswordLenght = minPassLenght;
|
||||
|
||||
_manager = [AFHTTPSessionManager manager];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) setEnvironment:(Environment) env {
|
||||
|
||||
_currentEnvironment = nil;
|
||||
|
||||
switch (env) {
|
||||
case Development:{
|
||||
if (_devEnabled) {
|
||||
_currentEnvironment = [_configuration objectForKey:EnvironmentDevelopment];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Stage:{
|
||||
if (_stageEnabled) {
|
||||
_currentEnvironment = [_configuration objectForKey:EnvironmentStage];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Production:
|
||||
default:
|
||||
if (_productionEnabled) {
|
||||
_currentEnvironment = [_configuration objectForKey:EnvironmentProduction];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
NSAssert(_currentEnvironment,@"Selected environment generate error. Please check configuration");
|
||||
|
||||
|
||||
_currentEnvironment = nil;
|
||||
|
||||
switch (env) {
|
||||
case Development:{
|
||||
if (_devEnabled) {
|
||||
_currentEnvironment = [_configuration objectForKey:EnvironmentDevelopment];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Stage:{
|
||||
if (_stageEnabled) {
|
||||
_currentEnvironment = [_configuration objectForKey:EnvironmentStage];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Production:
|
||||
default:
|
||||
if (_productionEnabled) {
|
||||
_currentEnvironment = [_configuration objectForKey:EnvironmentProduction];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
NSAssert(_currentEnvironment,@"Selected environment generate error. Please check configuration");
|
||||
|
||||
}
|
||||
|
||||
- (NSString *) PNObjEndpoint {
|
||||
return _currentEnvironment;
|
||||
return _currentEnvironment;
|
||||
}
|
||||
|
||||
- (void) setAcceptablePasswordLenght:(NSUInteger) passLenght {
|
||||
_minPasswordLenght = passLenght;
|
||||
_minPasswordLenght = passLenght;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user