- Fix vari
This commit is contained in:
parent
c3e77e7a09
commit
e2e17186ac
@ -30,6 +30,8 @@
|
||||
<array>
|
||||
<string>armv7</string>
|
||||
</array>
|
||||
<key>UIRequiresFullScreen</key>
|
||||
<true/>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
@ -43,5 +45,24 @@
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>NSAppTransportSecurity</key>
|
||||
<dict>
|
||||
<key>NSAllowsArbitraryLoads</key>
|
||||
<true/>
|
||||
<key>NSExceptionDomains</key>
|
||||
<dict>
|
||||
<key>giuseppenucifora.com</key>
|
||||
<dict>
|
||||
<key>NSIncludesSubdomains</key>
|
||||
<true/>
|
||||
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
|
||||
<true/>
|
||||
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
|
||||
<true/>
|
||||
<key>NSTemporaryExceptionMinimumTLSVersion</key>
|
||||
<string>TLSv1.1</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
@ -14,10 +14,16 @@
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
||||
{
|
||||
// Override point for customization after application launch.
|
||||
[PNObjectConfig sharedInstanceForEnvironments:@{ EnvironmentDevelopment : @"https://development.it/api/v1",
|
||||
[PNObjectConfig initSharedInstanceForEnvironments:@{ EnvironmentDevelopment : @"https://development.it/api/v1",
|
||||
EnvironmentStage : @"https://stage.it/api/v1",
|
||||
//EnvironmentProduction : @"https://production.it/api/v1"
|
||||
EnvironmentProduction : @"http://pnobjectdemo.giuseppenucifora.com/"
|
||||
}];
|
||||
|
||||
[[PNObjectConfig sharedInstance] setEnvironment:Production];
|
||||
|
||||
|
||||
[PNObject get];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@ target 'PNObject_Example' do
|
||||
pod 'PEAR-FileManager-iOS'
|
||||
pod 'NSDate_Utils'
|
||||
pod 'UIDevice-Utils'
|
||||
pod 'AFNetworking',
|
||||
pod 'AFNetworking'
|
||||
end
|
||||
|
||||
target 'PNObject_Tests' do
|
||||
|
||||
@ -25,7 +25,8 @@ PODS:
|
||||
- FBSnapshotTestCase/Core
|
||||
- NSDate_Utils (0.1.0)
|
||||
- PEAR-FileManager-iOS (1.3.1)
|
||||
- PNObject (0.1.0)
|
||||
- PNObject (0.3.0):
|
||||
- AFNetworking
|
||||
- Specta (1.0.5)
|
||||
- UIDevice-Utils (0.1.2)
|
||||
|
||||
@ -51,10 +52,10 @@ SPEC CHECKSUMS:
|
||||
FBSnapshotTestCase: 7e85180d0d141a0cf472352edda7e80d7eaeb547
|
||||
NSDate_Utils: 4a57f91094123d5b7600c7de8c9ad9e1d43306a3
|
||||
PEAR-FileManager-iOS: 3bc403f68a53483f5629aa822f4649e40275c4d3
|
||||
PNObject: c76ad7edcc1e09717e48eb9554f6d6eb422ea70e
|
||||
PNObject: f877cd7a8f05f0408052f27829ba130292806ccc
|
||||
Specta: ac94d110b865115fe60ff2c6d7281053c6f8e8a2
|
||||
UIDevice-Utils: 14362004e88f8cc05d8ec68369724a5972faadec
|
||||
|
||||
PODFILE CHECKSUM: 6a156edc70605054ee3ec9b0a6d6af416e100bf0
|
||||
PODFILE CHECKSUM: 1ea746664adf2b8032990de100ad004837d156f9
|
||||
|
||||
COCOAPODS: 1.0.0.beta.2
|
||||
|
||||
13
Example/Pods/Local Podspecs/PNObject.podspec.json
generated
13
Example/Pods/Local Podspecs/PNObject.podspec.json
generated
@ -1,15 +1,15 @@
|
||||
{
|
||||
"name": "PNObject",
|
||||
"version": "0.1.0",
|
||||
"version": "0.3.0",
|
||||
"summary": "A short description of PNObject.",
|
||||
"homepage": "https://github.com/<GITHUB_USERNAME>/PNObject",
|
||||
"homepage": "https://github.com/giuseppenucifora/PNObject",
|
||||
"license": "MIT",
|
||||
"authors": {
|
||||
"Giuseppe Nucifora": "me@giuseppenucifora.com"
|
||||
},
|
||||
"source": {
|
||||
"git": "https://github.com/<GITHUB_USERNAME>/PNObject.git",
|
||||
"tag": "0.1.0"
|
||||
"git": "https://github.com/giuseppenucifora/PNObject.git",
|
||||
"tag": "0.3.0"
|
||||
},
|
||||
"platforms": {
|
||||
"ios": "7.0"
|
||||
@ -20,5 +20,10 @@
|
||||
"PNObject": [
|
||||
"Pod/Assets/*.png"
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"AFNetworking": [
|
||||
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
7
Example/Pods/Manifest.lock
generated
7
Example/Pods/Manifest.lock
generated
@ -25,7 +25,8 @@ PODS:
|
||||
- FBSnapshotTestCase/Core
|
||||
- NSDate_Utils (0.1.0)
|
||||
- PEAR-FileManager-iOS (1.3.1)
|
||||
- PNObject (0.1.0)
|
||||
- PNObject (0.3.0):
|
||||
- AFNetworking
|
||||
- Specta (1.0.5)
|
||||
- UIDevice-Utils (0.1.2)
|
||||
|
||||
@ -51,10 +52,10 @@ SPEC CHECKSUMS:
|
||||
FBSnapshotTestCase: 7e85180d0d141a0cf472352edda7e80d7eaeb547
|
||||
NSDate_Utils: 4a57f91094123d5b7600c7de8c9ad9e1d43306a3
|
||||
PEAR-FileManager-iOS: 3bc403f68a53483f5629aa822f4649e40275c4d3
|
||||
PNObject: c76ad7edcc1e09717e48eb9554f6d6eb422ea70e
|
||||
PNObject: f877cd7a8f05f0408052f27829ba130292806ccc
|
||||
Specta: ac94d110b865115fe60ff2c6d7281053c6f8e8a2
|
||||
UIDevice-Utils: 14362004e88f8cc05d8ec68369724a5972faadec
|
||||
|
||||
PODFILE CHECKSUM: 6a156edc70605054ee3ec9b0a6d6af416e100bf0
|
||||
PODFILE CHECKSUM: 1ea746664adf2b8032990de100ad004837d156f9
|
||||
|
||||
COCOAPODS: 1.0.0.beta.2
|
||||
|
||||
1476
Example/Pods/Pods.xcodeproj/project.pbxproj
generated
1476
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 = 'B9CEE2C8E8D9960342F45DDE'
|
||||
BlueprintIdentifier = 'F6218C00F6F447EBE8284238'
|
||||
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.3.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
|
||||
@ -1,7 +1,12 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import "PNObject.h"
|
||||
#import "PNObjectConfig.h"
|
||||
#import "PNObjectProperty.h"
|
||||
#import "PNObjectSubclassing.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.3.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
|
||||
@ -1,6 +1,29 @@
|
||||
# Acknowledgements
|
||||
This application makes use of the following third party libraries:
|
||||
|
||||
## AFNetworking
|
||||
|
||||
Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
## PNObject
|
||||
|
||||
Copyright (c) 2015 Giuseppe Nucifora <me@giuseppenucifora.com>
|
||||
|
||||
@ -12,6 +12,33 @@
|
||||
<key>Type</key>
|
||||
<string>PSGroupSpecifier</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>FooterText</key>
|
||||
<string>Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
</string>
|
||||
<key>Title</key>
|
||||
<string>AFNetworking</string>
|
||||
<key>Type</key>
|
||||
<string>PSGroupSpecifier</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>FooterText</key>
|
||||
<string>Copyright (c) 2015 Giuseppe Nucifora <me@giuseppenucifora.com>
|
||||
|
||||
@ -84,6 +84,7 @@ strip_invalid_archs() {
|
||||
|
||||
|
||||
if [[ "$CONFIGURATION" == "Debug" ]]; then
|
||||
install_framework "Pods-PNObject_Tests/AFNetworking.framework"
|
||||
install_framework "Pods-PNObject_Tests/PNObject.framework"
|
||||
install_framework "Pods-PNObject_Tests/Expecta.framework"
|
||||
install_framework "Pods-PNObject_Tests/Expecta_Snapshots.framework"
|
||||
@ -91,6 +92,7 @@ if [[ "$CONFIGURATION" == "Debug" ]]; then
|
||||
install_framework "Pods-PNObject_Tests/Specta.framework"
|
||||
fi
|
||||
if [[ "$CONFIGURATION" == "Release" ]]; then
|
||||
install_framework "Pods-PNObject_Tests/AFNetworking.framework"
|
||||
install_framework "Pods-PNObject_Tests/PNObject.framework"
|
||||
install_framework "Pods-PNObject_Tests/Expecta.framework"
|
||||
install_framework "Pods-PNObject_Tests/Expecta_Snapshots.framework"
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
|
||||
LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
|
||||
OTHER_CFLAGS = $(inherited) -iquote "$CONFIGURATION_BUILD_DIR/Expecta.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/Expecta_Snapshots.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/FBSnapshotTestCase.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/PNObject.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/Specta.framework/Headers"
|
||||
OTHER_LDFLAGS = $(inherited) -framework "Expecta" -framework "Expecta_Snapshots" -framework "FBSnapshotTestCase" -framework "PNObject" -framework "Specta"
|
||||
OTHER_CFLAGS = $(inherited) -iquote "$CONFIGURATION_BUILD_DIR/AFNetworking.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/Expecta.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/Expecta_Snapshots.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/FBSnapshotTestCase.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/PNObject.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/Specta.framework/Headers"
|
||||
OTHER_LDFLAGS = $(inherited) -framework "AFNetworking" -framework "Expecta" -framework "Expecta_Snapshots" -framework "FBSnapshotTestCase" -framework "PNObject" -framework "Specta"
|
||||
OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS"
|
||||
PODS_FRAMEWORK_BUILD_PATH = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/Pods-PNObject_Tests
|
||||
PODS_ROOT = ${SRCROOT}/Pods
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
|
||||
LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
|
||||
OTHER_CFLAGS = $(inherited) -iquote "$CONFIGURATION_BUILD_DIR/Expecta.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/Expecta_Snapshots.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/FBSnapshotTestCase.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/PNObject.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/Specta.framework/Headers"
|
||||
OTHER_LDFLAGS = $(inherited) -framework "Expecta" -framework "Expecta_Snapshots" -framework "FBSnapshotTestCase" -framework "PNObject" -framework "Specta"
|
||||
OTHER_CFLAGS = $(inherited) -iquote "$CONFIGURATION_BUILD_DIR/AFNetworking.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/Expecta.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/Expecta_Snapshots.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/FBSnapshotTestCase.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/PNObject.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/Specta.framework/Headers"
|
||||
OTHER_LDFLAGS = $(inherited) -framework "AFNetworking" -framework "Expecta" -framework "Expecta_Snapshots" -framework "FBSnapshotTestCase" -framework "PNObject" -framework "Specta"
|
||||
OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS"
|
||||
PODS_FRAMEWORK_BUILD_PATH = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/Pods-PNObject_Tests
|
||||
PODS_ROOT = ${SRCROOT}/Pods
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "PNObject"
|
||||
s.version = "0.1.0"
|
||||
s.version = "0.3.0"
|
||||
s.summary = "A short description of PNObject."
|
||||
|
||||
# This description is used to generate tags and improve search results.
|
||||
@ -35,5 +35,5 @@ Pod::Spec.new do |s|
|
||||
|
||||
# s.public_header_files = 'Pod/Classes/**/*.h'
|
||||
# s.frameworks = 'UIKit', 'MapKit'
|
||||
# s.dependency 'AFNetworking', '~> 2.3'
|
||||
s.dependency 'AFNetworking'
|
||||
end
|
||||
|
||||
@ -10,7 +10,8 @@
|
||||
#import "PNObjectSubclassing.h"
|
||||
#import "PNObjectConfig.h"
|
||||
|
||||
@interface PNObject : NSObject <PNObjectSubclassing>
|
||||
|
||||
@interface PNObject : NSObject
|
||||
|
||||
@property (nonatomic, strong) NSString *objID;
|
||||
@property (nonatomic, strong) NSDate *createdDate;
|
||||
@ -18,6 +19,5 @@
|
||||
|
||||
- (instancetype) initWithJSON:(NSDictionary*) JSON;
|
||||
|
||||
|
||||
|
||||
+ (void) get;
|
||||
@end
|
||||
|
||||
@ -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
|
||||
|
||||
@ -26,6 +26,8 @@ extern NSString* const EnvironmentDevelopment;
|
||||
* gets singleton object.
|
||||
* @return singleton
|
||||
*/
|
||||
+ (instancetype) sharedInstance;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
@ -38,10 +40,10 @@ extern NSString* const EnvironmentDevelopment;
|
||||
*
|
||||
* @return singleton
|
||||
*/
|
||||
+ (instancetype) sharedInstanceForEnvironments:(NSDictionary *) endpointUrlsForEnvironments;
|
||||
|
||||
- (void) enableEnvironment:(Environment) env;
|
||||
+ (instancetype) initSharedInstanceForEnvironments:(NSDictionary *) endpointUrlsForEnvironments;
|
||||
|
||||
- (void) setEnvironment:(Environment) env;
|
||||
|
||||
- (NSString *) PNObjEndpoint;
|
||||
|
||||
@end
|
||||
@ -16,10 +16,12 @@ NSString* const EnvironmentDevelopment = @"PNObjectConfigDevelopment";
|
||||
@interface PNObjectConfig()
|
||||
|
||||
@property (nonatomic, strong) NSMutableDictionary *configuration;
|
||||
@property (nonatomic, strong) NSString *currentEnvironment;
|
||||
@property (nonatomic) BOOL devEnabled;
|
||||
@property (nonatomic) BOOL stageEnabled;
|
||||
@property (nonatomic) BOOL productionEnabled;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@implementation PNObjectConfig
|
||||
@ -32,7 +34,7 @@ static bool isFirstAccess = YES;
|
||||
|
||||
#pragma mark - Public Method
|
||||
|
||||
+ (id)sharedInstance
|
||||
+ (instancetype)sharedInstance
|
||||
{
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
@ -45,7 +47,7 @@ static bool isFirstAccess = YES;
|
||||
|
||||
#pragma mark - Life Cycle
|
||||
|
||||
+ (instancetype) sharedInstanceForEnvironments:(NSDictionary *) endpointUrlsForEnvironments {
|
||||
+ (instancetype) initSharedInstanceForEnvironments:(NSDictionary *) endpointUrlsForEnvironments {
|
||||
SINGLETON = [self sharedInstance];
|
||||
|
||||
if (SINGLETON) {
|
||||
@ -55,7 +57,7 @@ static bool isFirstAccess = YES;
|
||||
EnvironmentDevelopment : ^{
|
||||
NSURL * endpointUrl = [NSURL URLWithString:[endpointUrlsForEnvironments objectForKey:key]];
|
||||
if (endpointUrl) {
|
||||
[SINGLETON.configuration setValue:endpointUrl forKey:key];
|
||||
[SINGLETON.configuration setValue:[endpointUrl absoluteString] forKey:key];
|
||||
SINGLETON.devEnabled = YES;
|
||||
}
|
||||
|
||||
@ -63,14 +65,14 @@ static bool isFirstAccess = YES;
|
||||
EnvironmentStage : ^{
|
||||
NSURL * endpointUrl = [NSURL URLWithString:[endpointUrlsForEnvironments objectForKey:key]];
|
||||
if (endpointUrl) {
|
||||
[SINGLETON.configuration setValue:endpointUrl forKey:key];
|
||||
[SINGLETON.configuration setValue:[endpointUrl absoluteString] forKey:key];
|
||||
SINGLETON.stageEnabled = YES;
|
||||
}
|
||||
},
|
||||
EnvironmentProduction : ^{
|
||||
NSURL * endpointUrl = [NSURL URLWithString:[endpointUrlsForEnvironments objectForKey:key]];
|
||||
if (endpointUrl) {
|
||||
[SINGLETON.configuration setValue:endpointUrl forKey:key];
|
||||
[SINGLETON.configuration setValue:[endpointUrl absoluteString] forKey:key];
|
||||
SINGLETON.productionEnabled = YES;
|
||||
}
|
||||
}
|
||||
@ -79,8 +81,8 @@ static bool isFirstAccess = YES;
|
||||
})();
|
||||
}
|
||||
NSAssert(SINGLETON.productionEnabled, @"EnvironmentProduction must be valid endpoint url");
|
||||
SINGLETON.currentEnvironment = [[SINGLETON configuration] objectForKey:EnvironmentProduction];
|
||||
|
||||
NSLog(@"Config : %@",SINGLETON.configuration);
|
||||
}
|
||||
return SINGLETON;
|
||||
}
|
||||
@ -126,21 +128,37 @@ static bool isFirstAccess = YES;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) enableEnvironment:(Environment) env {
|
||||
- (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");
|
||||
|
||||
}
|
||||
|
||||
- (NSString *) PNObjEndpoint {
|
||||
return _currentEnvironment;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
23
Pod/Classes/User/PNAddress.h
Normal file
23
Pod/Classes/User/PNAddress.h
Normal file
@ -0,0 +1,23 @@
|
||||
//
|
||||
// PNAddress.h
|
||||
// Pods
|
||||
//
|
||||
// Created by Giuseppe Nucifora on 13/01/16.
|
||||
//
|
||||
//
|
||||
|
||||
#import <PNObject/PNObject.h>
|
||||
#import "PNLocation.h"
|
||||
|
||||
@interface PNAddress : PNObject <PNObjectSubclassing>
|
||||
|
||||
@property (nonatomic, strong) NSString *country;
|
||||
@property (nonatomic, strong) NSString *province;
|
||||
@property (nonatomic, strong) NSString *city;
|
||||
@property (nonatomic, strong) NSString *street;
|
||||
@property (nonatomic, strong) NSNumber *number;
|
||||
@property (nonatomic, strong) NSString *zip;
|
||||
@property (nonatomic, strong) NSString *istruction;
|
||||
@property (nonatomic, strong) PNLocation *location;
|
||||
|
||||
@end
|
||||
29
Pod/Classes/User/PNAddress.m
Normal file
29
Pod/Classes/User/PNAddress.m
Normal file
@ -0,0 +1,29 @@
|
||||
//
|
||||
// PNAddress.m
|
||||
// Pods
|
||||
//
|
||||
// Created by Giuseppe Nucifora on 13/01/16.
|
||||
//
|
||||
//
|
||||
|
||||
#import "PNAddress.h"
|
||||
|
||||
@implementation PNAddress
|
||||
|
||||
+ (NSString *) objectClassName {
|
||||
return @"Address";
|
||||
}
|
||||
|
||||
+ (NSDictionary *) objcetMapping {
|
||||
NSDictionary *mapping = @{@"country":@"country",
|
||||
@"province":@"province",
|
||||
@"city":@"city",
|
||||
@"street":@"street",
|
||||
@"number":@"number",
|
||||
@"zip":@"zip",
|
||||
@"location":@{@"key":@"location",@"type":@"PNLocation"},
|
||||
};
|
||||
return mapping;
|
||||
}
|
||||
|
||||
@end
|
||||
16
Pod/Classes/User/PNLocation.h
Normal file
16
Pod/Classes/User/PNLocation.h
Normal file
@ -0,0 +1,16 @@
|
||||
//
|
||||
// PNLocation.h
|
||||
// Pods
|
||||
//
|
||||
// Created by Giuseppe Nucifora on 13/01/16.
|
||||
//
|
||||
//
|
||||
|
||||
#import <PNObject/PNObject.h>
|
||||
|
||||
@interface PNLocation : PNObject <PNObjectSubclassing>
|
||||
|
||||
@property (nonatomic) CGFloat lat;
|
||||
@property (nonatomic) CGFloat lng;
|
||||
|
||||
@end
|
||||
25
Pod/Classes/User/PNLocation.m
Normal file
25
Pod/Classes/User/PNLocation.m
Normal file
@ -0,0 +1,25 @@
|
||||
//
|
||||
// PNLocation.m
|
||||
// Pods
|
||||
//
|
||||
// Created by Giuseppe Nucifora on 13/01/16.
|
||||
//
|
||||
//
|
||||
|
||||
#import "PNLocation.h"
|
||||
|
||||
@implementation PNLocation
|
||||
|
||||
+ (NSString *) objectClassName {
|
||||
return @"Location";
|
||||
}
|
||||
|
||||
|
||||
+ (NSDictionary *) objcetMapping {
|
||||
NSDictionary *mapping = @{@"lat":@"lat",
|
||||
@"lng":@"lng",
|
||||
};
|
||||
return mapping;
|
||||
}
|
||||
|
||||
@end
|
||||
36
Pod/Classes/User/PNUser.h
Normal file
36
Pod/Classes/User/PNUser.h
Normal file
@ -0,0 +1,36 @@
|
||||
//
|
||||
// PNUser.h
|
||||
// Pods
|
||||
//
|
||||
// Created by Giuseppe Nucifora on 08/01/16.
|
||||
//
|
||||
//
|
||||
|
||||
#import <PNObject/PNObject.h>
|
||||
#import "PNAddress.h"
|
||||
|
||||
@interface PNUser : PNObject <PNObjectSubclassing>
|
||||
|
||||
@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;
|
||||
|
||||
|
||||
|
||||
@end
|
||||
64
Pod/Classes/User/PNUser.m
Normal file
64
Pod/Classes/User/PNUser.m
Normal file
@ -0,0 +1,64 @@
|
||||
//
|
||||
// PNUser.m
|
||||
// Pods
|
||||
//
|
||||
// Created by Giuseppe Nucifora on 08/01/16.
|
||||
//
|
||||
//
|
||||
|
||||
#import "PNUser.h"
|
||||
|
||||
@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;
|
||||
*/
|
||||
|
||||
+ (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
|
||||
@ -1,13 +0,0 @@
|
||||
//
|
||||
// User.h
|
||||
// Pods
|
||||
//
|
||||
// Created by Giuseppe Nucifora on 08/01/16.
|
||||
//
|
||||
//
|
||||
|
||||
#import <PNObject/PNObject.h>
|
||||
|
||||
@interface User : PNObject
|
||||
|
||||
@end
|
||||
@ -1,22 +0,0 @@
|
||||
//
|
||||
// User.m
|
||||
// Pods
|
||||
//
|
||||
// Created by Giuseppe Nucifora on 08/01/16.
|
||||
//
|
||||
//
|
||||
|
||||
#import "User.h"
|
||||
|
||||
@implementation User
|
||||
|
||||
- (instancetype) initWithJSON:(NSDictionary *)JSON {
|
||||
|
||||
self = [super initWithJSON:JSON];
|
||||
if (self) {
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
43
README.md
43
README.md
@ -20,6 +20,49 @@ it, simply add the following line to your Podfile:
|
||||
pod "PNObject"
|
||||
```
|
||||
|
||||
##Usage Example
|
||||
|
||||
PNObject Subclass
|
||||
|
||||
```ruby
|
||||
Customer.h
|
||||
|
||||
#import <PNObject/PNObject.h>
|
||||
|
||||
@interface Customer : PNObject <PNObjectSubclassing>
|
||||
|
||||
@property (nonatomic, strong) NSString *name;
|
||||
@property (nonatomic, strong) NSString *lastName;
|
||||
@property (nonatomic, strong) NSString *email;
|
||||
@property (nonatomic, strong) NSDate *birthDate;
|
||||
@property (nonatomic, strong) PNAddress *address;
|
||||
|
||||
@end
|
||||
```
|
||||
|
||||
```ruby
|
||||
#import "Customer.h"
|
||||
|
||||
@implementation Customer
|
||||
|
||||
+ (NSString *) objectClassName {
|
||||
return @"Customer";
|
||||
}
|
||||
|
||||
|
||||
+ (NSDictionary *) objcetMapping {
|
||||
NSDictionary *mapping = @{
|
||||
@"name":@"first_name",
|
||||
@"surname":@"last_name",
|
||||
@"email":@"email",
|
||||
@"birthDate":@"birth_date",
|
||||
@"address":@{@"key":@"address",@"type":@"PNAddress"},
|
||||
};
|
||||
return mapping;
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## Author
|
||||
|
||||
Giuseppe Nucifora, me@giuseppenucifora.com
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user