- ADD PNObjectConfig Class

- ADD PNObjectSubclassing Protocol
This commit is contained in:
Giuseppe Nucifora 2016-01-08 20:21:22 +01:00
parent 568ad5c409
commit c3e77e7a09
22 changed files with 334 additions and 109 deletions

View File

@ -246,7 +246,7 @@
isa = PBXProject; isa = PBXProject;
attributes = { attributes = {
CLASSPREFIX = PNObject; CLASSPREFIX = PNObject;
LastUpgradeCheck = 0510; LastUpgradeCheck = 0720;
ORGANIZATIONNAME = "Giuseppe Nucifora"; ORGANIZATIONNAME = "Giuseppe Nucifora";
TargetAttributes = { TargetAttributes = {
6003F5AD195388D20070C39A = { 6003F5AD195388D20070C39A = {
@ -454,6 +454,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99; GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO; GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0; GCC_OPTIMIZATION_LEVEL = 0;
@ -468,7 +469,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 7.1; IPHONEOS_DEPLOYMENT_TARGET = 8.0;
ONLY_ACTIVE_ARCH = YES; ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos; SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";
@ -501,7 +502,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 7.1; IPHONEOS_DEPLOYMENT_TARGET = 8.0;
SDKROOT = iphoneos; SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES; VALIDATE_PRODUCT = YES;
@ -517,7 +518,9 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "PNObject/PNObject-Prefix.pch"; GCC_PREFIX_HEADER = "PNObject/PNObject-Prefix.pch";
INFOPLIST_FILE = "PNObject/PNObject-Info.plist"; INFOPLIST_FILE = "PNObject/PNObject-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MODULE_NAME = ExampleApp; MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app; WRAPPER_EXTENSION = app;
}; };
@ -532,7 +535,9 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "PNObject/PNObject-Prefix.pch"; GCC_PREFIX_HEADER = "PNObject/PNObject-Prefix.pch";
INFOPLIST_FILE = "PNObject/PNObject-Info.plist"; INFOPLIST_FILE = "PNObject/PNObject-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MODULE_NAME = ExampleApp; MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app; WRAPPER_EXTENSION = app;
}; };
@ -555,6 +560,7 @@
"$(inherited)", "$(inherited)",
); );
INFOPLIST_FILE = "Tests/Tests-Info.plist"; INFOPLIST_FILE = "Tests/Tests-Info.plist";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PNObject_Example.app/PNObject_Example"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PNObject_Example.app/PNObject_Example";
WRAPPER_EXTENSION = xctest; WRAPPER_EXTENSION = xctest;
@ -574,6 +580,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Tests/Tests-Prefix.pch"; GCC_PREFIX_HEADER = "Tests/Tests-Prefix.pch";
INFOPLIST_FILE = "Tests/Tests-Info.plist"; INFOPLIST_FILE = "Tests/Tests-Info.plist";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PNObject_Example.app/PNObject_Example"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PNObject_Example.app/PNObject_Example";
WRAPPER_EXTENSION = xctest; WRAPPER_EXTENSION = xctest;

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Scheme <Scheme
LastUpgradeVersion = "0600" LastUpgradeVersion = "0720"
version = "1.3"> version = "1.3">
<BuildAction <BuildAction
parallelizeBuildables = "YES" parallelizeBuildables = "YES"
@ -23,10 +23,10 @@
</BuildActionEntries> </BuildActionEntries>
</BuildAction> </BuildAction>
<TestAction <TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES" shouldUseLaunchSchemeArgsEnv = "YES">
buildConfiguration = "Debug">
<Testables> <Testables>
<TestableReference <TestableReference
skipped = "NO"> skipped = "NO">
@ -48,15 +48,18 @@
ReferencedContainer = "container:PNObject.xcodeproj"> ReferencedContainer = "container:PNObject.xcodeproj">
</BuildableReference> </BuildableReference>
</MacroExpansion> </MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction> </TestAction>
<LaunchAction <LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0" launchStyle = "0"
useCustomWorkingDirectory = "NO" useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO" ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES" debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES"> allowLocationSimulation = "YES">
<BuildableProductRunnable <BuildableProductRunnable
runnableDebuggingMode = "0"> runnableDebuggingMode = "0">
@ -72,10 +75,10 @@
</AdditionalOptions> </AdditionalOptions>
</LaunchAction> </LaunchAction>
<ProfileAction <ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES" shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = "" savedToolIdentifier = ""
useCustomWorkingDirectory = "NO" useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES"> debugDocumentVersioning = "YES">
<BuildableProductRunnable <BuildableProductRunnable
runnableDebuggingMode = "0"> runnableDebuggingMode = "0">

View File

@ -9,7 +9,7 @@
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string> <string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
<string>org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}</string> <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key> <key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string> <string>6.0</string>
<key>CFBundleName</key> <key>CFBundleName</key>

View File

@ -7,12 +7,17 @@
// //
#import "PNObjectAppDelegate.h" #import "PNObjectAppDelegate.h"
#import "PNObject.h"
@implementation PNObjectAppDelegate @implementation PNObjectAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{ {
// Override point for customization after application launch. // Override point for customization after application launch.
[PNObjectConfig sharedInstanceForEnvironments:@{ EnvironmentDevelopment : @"https://development.it/api/v1",
EnvironmentStage : @"https://stage.it/api/v1",
//EnvironmentProduction : @"https://production.it/api/v1"
}];
return YES; return YES;
} }

View File

@ -9,6 +9,7 @@
#import "PNObjectViewController.h" #import "PNObjectViewController.h"
//#import "PNObject.h" //#import "PNObject.h"
@interface PNObjectViewController () @interface PNObjectViewController ()
@end @end
@ -18,7 +19,7 @@
- (void)viewDidLoad - (void)viewDidLoad
{ {
[super viewDidLoad]; [super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib. // Do any additional setup after loading the view, typically from a nib.
} }
- (void)didReceiveMemoryWarning - (void)didReceiveMemoryWarning

View File

@ -8,7 +8,7 @@ target 'PNObject_Example' do
pod 'PEAR-FileManager-iOS' pod 'PEAR-FileManager-iOS'
pod 'NSDate_Utils' pod 'NSDate_Utils'
pod 'UIDevice-Utils' pod 'UIDevice-Utils'
pod 'AFNetworking' pod 'AFNetworking',
end end
target 'PNObject_Tests' do target 'PNObject_Tests' do

View File

@ -57,4 +57,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: 6a156edc70605054ee3ec9b0a6d6af416e100bf0 PODFILE CHECKSUM: 6a156edc70605054ee3ec9b0a6d6af416e100bf0
COCOAPODS: 1.0.0.beta.1 COCOAPODS: 1.0.0.beta.2

View File

@ -57,4 +57,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: 6a156edc70605054ee3ec9b0a6d6af416e100bf0 PODFILE CHECKSUM: 6a156edc70605054ee3ec9b0a6d6af416e100bf0
COCOAPODS: 1.0.0.beta.1 COCOAPODS: 1.0.0.beta.2

View File

@ -101,6 +101,12 @@
66A27898E989A3FA5C15AA671C4536F0 /* EXPMatchers+beIdenticalTo.m in Sources */ = {isa = PBXBuildFile; fileRef = ABC2BD19C88FB68928A4ACDD68A9A724 /* EXPMatchers+beIdenticalTo.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; 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, ); }; }; 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, ); }; }; 68152D921ABF6A423C192C04FDF94F0F /* AFNetworkReachabilityManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 6D147D9B92257C3B94B576C35DC424BF /* AFNetworkReachabilityManager.h */; settings = {ATTRIBUTES = (Public, ); }; };
6836B1401C40187C00FEFA54 /* User.h in Headers */ = {isa = PBXBuildFile; fileRef = 6836B13E1C40187C00FEFA54 /* User.h */; settings = {ATTRIBUTES = (Public, ); }; };
6836B1411C40187C00FEFA54 /* User.m in Sources */ = {isa = PBXBuildFile; fileRef = 6836B13F1C40187C00FEFA54 /* User.m */; };
685036881C402C0F00202BC4 /* PNObjectSubclassing.h in Headers */ = {isa = PBXBuildFile; fileRef = 685036871C402C0F00202BC4 /* PNObjectSubclassing.h */; };
6850368C1C403F0D00202BC4 /* PNObjectSubclassing.h in Headers */ = {isa = PBXBuildFile; fileRef = 685036871C402C0F00202BC4 /* PNObjectSubclassing.h */; settings = {ATTRIBUTES = (Public, ); }; };
6850368D1C403F2C00202BC4 /* PNObjectConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = 6850368A1C40331900202BC4 /* PNObjectConfig.h */; settings = {ATTRIBUTES = (Public, ); }; };
6850368E1C40418E00202BC4 /* PNObjectConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = 6850368B1C40331900202BC4 /* PNObjectConfig.m */; };
68A38977EBAE334DC3C22386D00D2622 /* AFNetworkReachabilityManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 01C0656AD6CD15FA1E1CD0B12E72DBAC /* AFNetworkReachabilityManager.m */; }; 68A38977EBAE334DC3C22386D00D2622 /* AFNetworkReachabilityManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 01C0656AD6CD15FA1E1CD0B12E72DBAC /* AFNetworkReachabilityManager.m */; };
6B8F67BF9EF9C0D399893E9C92482D49 /* SpectaUtility.h in Headers */ = {isa = PBXBuildFile; fileRef = 0E49D273A400D01F7C968DEDB310739A /* SpectaUtility.h */; settings = {ATTRIBUTES = (Public, ); }; }; 6B8F67BF9EF9C0D399893E9C92482D49 /* SpectaUtility.h in Headers */ = {isa = PBXBuildFile; fileRef = 0E49D273A400D01F7C968DEDB310739A /* SpectaUtility.h */; settings = {ATTRIBUTES = (Public, ); }; };
6E1D978790705E137FDE439AA68DD3AA /* EXPFloatTuple.h in Headers */ = {isa = PBXBuildFile; fileRef = 61F3C1DB6F4E00473063EACFC5515CC3 /* EXPFloatTuple.h */; settings = {ATTRIBUTES = (Public, ); }; }; 6E1D978790705E137FDE439AA68DD3AA /* EXPFloatTuple.h in Headers */ = {isa = PBXBuildFile; fileRef = 61F3C1DB6F4E00473063EACFC5515CC3 /* EXPFloatTuple.h */; settings = {ATTRIBUTES = (Public, ); }; };
@ -423,7 +429,12 @@
64ABF623C50C215070FC44795D797682 /* EXPMatchers+beKindOf.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "EXPMatchers+beKindOf.m"; path = "Expecta/Matchers/EXPMatchers+beKindOf.m"; sourceTree = "<group>"; }; 64ABF623C50C215070FC44795D797682 /* EXPMatchers+beKindOf.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "EXPMatchers+beKindOf.m"; path = "Expecta/Matchers/EXPMatchers+beKindOf.m"; sourceTree = "<group>"; };
64F490A38FEF85969F7D32CF7DAD9297 /* SPTSpec.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SPTSpec.m; path = Specta/Specta/SPTSpec.m; sourceTree = "<group>"; }; 64F490A38FEF85969F7D32CF7DAD9297 /* SPTSpec.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SPTSpec.m; path = Specta/Specta/SPTSpec.m; sourceTree = "<group>"; };
680CFD1FCDFA6B058464345597F0BBF0 /* EXPUnsupportedObject.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = EXPUnsupportedObject.h; path = Expecta/EXPUnsupportedObject.h; sourceTree = "<group>"; }; 680CFD1FCDFA6B058464345597F0BBF0 /* EXPUnsupportedObject.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = EXPUnsupportedObject.h; path = Expecta/EXPUnsupportedObject.h; sourceTree = "<group>"; };
6836B13E1C40187C00FEFA54 /* User.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = User.h; sourceTree = "<group>"; };
6836B13F1C40187C00FEFA54 /* User.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = User.m; sourceTree = "<group>"; };
684260D2513FE8AD036B49C00B805318 /* Expecta.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Expecta.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 684260D2513FE8AD036B49C00B805318 /* Expecta.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Expecta.framework; sourceTree = BUILT_PRODUCTS_DIR; };
685036871C402C0F00202BC4 /* PNObjectSubclassing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PNObjectSubclassing.h; sourceTree = "<group>"; };
6850368A1C40331900202BC4 /* PNObjectConfig.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PNObjectConfig.h; sourceTree = "<group>"; };
6850368B1C40331900202BC4 /* PNObjectConfig.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PNObjectConfig.m; sourceTree = "<group>"; };
69C520A4C76B14DB186E153AEE415291 /* SpectaTypes.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SpectaTypes.h; path = Specta/Specta/SpectaTypes.h; sourceTree = "<group>"; }; 69C520A4C76B14DB186E153AEE415291 /* SpectaTypes.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SpectaTypes.h; path = Specta/Specta/SpectaTypes.h; sourceTree = "<group>"; };
6A9C98362B8CD1F0E2749529D53DEE66 /* AFURLRequestSerialization.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFURLRequestSerialization.h; path = AFNetworking/AFURLRequestSerialization.h; sourceTree = "<group>"; }; 6A9C98362B8CD1F0E2749529D53DEE66 /* AFURLRequestSerialization.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFURLRequestSerialization.h; path = AFNetworking/AFURLRequestSerialization.h; sourceTree = "<group>"; };
6BCF0B57CC5FE7DB7261CE7C60EAE6C1 /* NSDate_Utils.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = NSDate_Utils.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 6BCF0B57CC5FE7DB7261CE7C60EAE6C1 /* NSDate_Utils.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = NSDate_Utils.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@ -958,6 +969,15 @@
path = AFNetworking; path = AFNetworking;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
6836B13D1C40185A00FEFA54 /* User */ = {
isa = PBXGroup;
children = (
6836B13E1C40187C00FEFA54 /* User.h */,
6836B13F1C40187C00FEFA54 /* User.m */,
);
path = User;
sourceTree = "<group>";
};
6963333AA224B56F4EA948D1389FFA46 /* UIDevice-Utils */ = { 6963333AA224B56F4EA948D1389FFA46 /* UIDevice-Utils */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
@ -1121,10 +1141,14 @@
AE64835AD928C05A0E07671000DB2081 /* Classes */ = { AE64835AD928C05A0E07671000DB2081 /* Classes */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
6836B13D1C40185A00FEFA54 /* User */,
E1E0780BB830EFAC797B401B279BC515 /* PNObject.h */, E1E0780BB830EFAC797B401B279BC515 /* PNObject.h */,
941FEF92BBC85C24850889688C55A31A /* PNObject.m */, 941FEF92BBC85C24850889688C55A31A /* PNObject.m */,
D0251859D2194B8DD130203343433439 /* PNObjectProperty.h */, D0251859D2194B8DD130203343433439 /* PNObjectProperty.h */,
570E079E6A901F2AD57E8F3241BCE8C3 /* PNObjectProperty.m */, 570E079E6A901F2AD57E8F3241BCE8C3 /* PNObjectProperty.m */,
685036871C402C0F00202BC4 /* PNObjectSubclassing.h */,
6850368A1C40331900202BC4 /* PNObjectConfig.h */,
6850368B1C40331900202BC4 /* PNObjectConfig.m */,
); );
path = Classes; path = Classes;
sourceTree = "<group>"; sourceTree = "<group>";
@ -1340,6 +1364,7 @@
659960F7E28E993E08CCC1E8A383E710 /* UIKit+AFNetworking.h in Headers */, 659960F7E28E993E08CCC1E8A383E710 /* UIKit+AFNetworking.h in Headers */,
D9F4E833E37B611B432F6B5D7072DDA2 /* UIProgressView+AFNetworking.h in Headers */, D9F4E833E37B611B432F6B5D7072DDA2 /* UIProgressView+AFNetworking.h in Headers */,
C6354FEC7728A4C86DAD8092509BA7D4 /* UIRefreshControl+AFNetworking.h in Headers */, C6354FEC7728A4C86DAD8092509BA7D4 /* UIRefreshControl+AFNetworking.h in Headers */,
685036881C402C0F00202BC4 /* PNObjectSubclassing.h in Headers */,
AE2A07407FB50BA249984DC0620E84C0 /* UIWebView+AFNetworking.h in Headers */, AE2A07407FB50BA249984DC0620E84C0 /* UIWebView+AFNetworking.h in Headers */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
@ -1406,6 +1431,9 @@
003FC52F29E9B9B55FFC8C2C1E57D6BE /* PNObject-umbrella.h in Headers */, 003FC52F29E9B9B55FFC8C2C1E57D6BE /* PNObject-umbrella.h in Headers */,
98A194768324928F76BF544EEE5EDBE5 /* PNObject.h in Headers */, 98A194768324928F76BF544EEE5EDBE5 /* PNObject.h in Headers */,
410F22568A4D148214B412697A2322E6 /* PNObjectProperty.h in Headers */, 410F22568A4D148214B412697A2322E6 /* PNObjectProperty.h in Headers */,
6850368C1C403F0D00202BC4 /* PNObjectSubclassing.h in Headers */,
6836B1401C40187C00FEFA54 /* User.h in Headers */,
6850368D1C403F2C00202BC4 /* PNObjectConfig.h in Headers */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -1825,9 +1853,11 @@
isa = PBXSourcesBuildPhase; isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
6836B1411C40187C00FEFA54 /* User.m in Sources */,
2FC59A81B07D43DCB4CAE4962F4A6018 /* PNObject-dummy.m in Sources */, 2FC59A81B07D43DCB4CAE4962F4A6018 /* PNObject-dummy.m in Sources */,
4E9495420371C304945421EA68F69B22 /* PNObject.m in Sources */, 4E9495420371C304945421EA68F69B22 /* PNObject.m in Sources */,
E1D01718CD5CFB570AE7B1D46BCE1436 /* PNObjectProperty.m in Sources */, E1D01718CD5CFB570AE7B1D46BCE1436 /* PNObjectProperty.m in Sources */,
6850368E1C40418E00202BC4 /* PNObjectConfig.m in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };

View File

@ -14,7 +14,7 @@
buildForArchiving = "YES"> buildForArchiving = "YES">
<BuildableReference <BuildableReference
BuildableIdentifier = 'primary' BuildableIdentifier = 'primary'
BlueprintIdentifier = '541DB431996AD480A19E5139' BlueprintIdentifier = 'B9CEE2C8E8D9960342F45DDE'
BlueprintName = 'PNObject' BlueprintName = 'PNObject'
ReferencedContainer = 'container:Pods.xcodeproj' ReferencedContainer = 'container:Pods.xcodeproj'
BuildableName = 'PNObject.framework'> BuildableName = 'PNObject.framework'>

View File

@ -4,8 +4,6 @@
<dict> <dict>
<key>CFBundleDevelopmentRegion</key> <key>CFBundleDevelopmentRegion</key>
<string>en</string> <string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string> <string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key> <key>CFBundleInfoDictionaryVersion</key>
@ -13,7 +11,7 @@
<key>CFBundleName</key> <key>CFBundleName</key>
<string>${PRODUCT_NAME}</string> <string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>FMWK</string> <string>BNDL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>0.1.0</string> <string>0.1.0</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>

View File

@ -4,8 +4,6 @@
<dict> <dict>
<key>CFBundleDevelopmentRegion</key> <key>CFBundleDevelopmentRegion</key>
<string>en</string> <string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string> <string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key> <key>CFBundleInfoDictionaryVersion</key>
@ -13,7 +11,7 @@
<key>CFBundleName</key> <key>CFBundleName</key>
<string>${PRODUCT_NAME}</string> <string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>FMWK</string> <string>BNDL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>0.1.0</string> <string>0.1.0</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>

View File

@ -4,8 +4,6 @@
<dict> <dict>
<key>CFBundleDevelopmentRegion</key> <key>CFBundleDevelopmentRegion</key>
<string>en</string> <string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string> <string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key> <key>CFBundleInfoDictionaryVersion</key>
@ -13,7 +11,7 @@
<key>CFBundleName</key> <key>CFBundleName</key>
<string>${PRODUCT_NAME}</string> <string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>FMWK</string> <string>BNDL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>0.1.2</string> <string>0.1.2</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>

View File

@ -7,7 +7,7 @@
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string> <string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
<string>org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}</string> <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key> <key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string> <string>6.0</string>
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>

View File

@ -18,11 +18,11 @@ Pod::Spec.new do |s|
# * Finally, don't worry about the indent, CocoaPods strips it! # * Finally, don't worry about the indent, CocoaPods strips it!
# s.description = <<-DESC DESC # s.description = <<-DESC DESC
s.homepage = "https://github.com/<GITHUB_USERNAME>/PNObject" s.homepage = "https://github.com/giuseppenucifora/PNObject"
# s.screenshots = "www.example.com/screenshots_1", "www.example.com/screenshots_2" # s.screenshots = "www.example.com/screenshots_1", "www.example.com/screenshots_2"
s.license = 'MIT' s.license = 'MIT'
s.author = { "Giuseppe Nucifora" => "me@giuseppenucifora.com" } s.author = { "Giuseppe Nucifora" => "me@giuseppenucifora.com" }
s.source = { :git => "https://github.com/<GITHUB_USERNAME>/PNObject.git", :tag => s.version.to_s } s.source = { :git => "https://github.com/giuseppenucifora/PNObject.git", :tag => s.version.to_s }
# s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>' # s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'
s.platform = :ios, '7.0' s.platform = :ios, '7.0'

View File

@ -7,8 +7,10 @@
// //
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import "PNObjectSubclassing.h"
#import "PNObjectConfig.h"
@interface PNObject : NSObject @interface PNObject : NSObject <PNObjectSubclassing>
@property (nonatomic, strong) NSString *objID; @property (nonatomic, strong) NSString *objID;
@property (nonatomic, strong) NSDate *createdDate; @property (nonatomic, strong) NSDate *createdDate;
@ -17,4 +19,5 @@
- (instancetype) initWithJSON:(NSDictionary*) JSON; - (instancetype) initWithJSON:(NSDictionary*) JSON;
@end @end

View File

@ -9,6 +9,7 @@
#import "PNObject.h" #import "PNObject.h"
#import <PNObjectProperty.h> #import <PNObjectProperty.h>
#import <NSDate_Utils/NSDate+NSDate_Util.h> #import <NSDate_Utils/NSDate+NSDate_Util.h>
#import <AFNetworking/AFNetworking.h>
@interface PNObject() @interface PNObject()
@ -24,7 +25,7 @@
self = [super init]; self = [super init];
if (self) { if (self) {
NSAssert(_objectMapping, @"You must create objectMapping");
} }
return self; return self;
@ -33,6 +34,7 @@
- (instancetype) initWithJSON:(NSDictionary*) JSON { - (instancetype) initWithJSON:(NSDictionary*) JSON {
self = [self init]; self = [self init];
if (self) { if (self) {
NSAssert(_objectMapping, @"You must create objectMapping");
_JSON = [[NSDictionary alloc] initWithDictionary:JSON]; _JSON = [[NSDictionary alloc] initWithDictionary:JSON];
[self populateObjectFromJSON:JSON]; [self populateObjectFromJSON:JSON];
@ -247,88 +249,20 @@
NSLog(@"%@",errorStr); NSLog(@"%@",errorStr);
} }
})(); })();
/*// char
if([propertyType isEqualToString:@"c"]) {
char val = [value charValue];
[self setValue:@(val) forKey:propertyName];
}
// double
else if([propertyType isEqualToString:@"d"]) {
double val = [value doubleValue];
[self setValue:@(val) forKey:propertyName];
}
// float
else if([propertyType isEqualToString:@"f"]) {
float val = [value floatValue];
[self setValue:@(val) forKey:propertyName];
}
// integer
else if([propertyType isEqualToString:@"i"]) {
int val = [value intValue];
[self setValue:@(val) forKey:propertyName];
}
// long
else if([propertyType isEqualToString:@"l"]) {
long val = [value longValue];
[self setValue:@(val) forKey:propertyName];
}
// short
else if([propertyType isEqualToString:@"s"]) {
short val = [value shortValue];
[self setValue:@(val) forKey:propertyName];
}
// NSString
else if([propertyType isEqualToString:@"NSString"]) {
NSString *val = [NSString stringWithFormat:@"%@", value];
[self setValue:val forKey:propertyName];
}
// NSNumber
else if([propertyType isEqualToString:@"NSNumber"]) {
NSInteger val = [value integerValue];
[self setValue:@(val) forKey:propertyName];
}
// NSDate
else if([propertyType isEqualToString:@"NSDate"]) {
NSString *str = [NSString stringWithFormat:@"%@", value];
NSDate *val = [NSDate dateFromString:str];
[self setValue:val forKey:propertyName];
}
// NSURL
else if([propertyType isEqualToString:@"NSURL"]) {
NSString *str = [NSString stringWithFormat:@"%@", value];
NSURL *val = [NSURL URLWithString:str];
[self setValue:val forKey:propertyName];
}
// NSArray, NSMutableArray
else if([propertyType isEqualToString:@"NSArray"] ||
[propertyType isEqualToString:@"NSMutableArray"]) {
NSMutableArray *arr = [NSMutableArray array];
for(id JSONObject in value) {
PNObject *val = [[NSClassFromString(mappedJSONType) alloc] initWithJSON:JSONObject];
[arr addObject:val];
}
[self setValue:arr forKey:propertyName];
}
// Other LLModel or an unidentified value
else {
BOOL isPNObjectSubclass = [NSClassFromString(propertyType) isSubclassOfClass:[PNObject class]];
if(isPNObjectSubclass) {
PNObject *val = [[NSClassFromString(propertyType) alloc] initWithJSON:value];
[self setValue:val forKey:propertyName];
}
else {
NSString *errorStr = [NSString stringWithFormat:@"Property '%@' could not be assigned any value.", propertyName];
NSLog(@"%@",errorStr);
}
}*/
} }
} }
#pragma mark PNObjectSubclassing
+ (NSString *) objectClassName {
}
+ (NSDictionary *) objcetMapping {
}
#pragma mark -
@end @end

View File

@ -0,0 +1,47 @@
//
// PNObjectConfig.h
// Pods
//
// Created by Giuseppe Nucifora on 08/01/16.
//
//
#import <Foundation/Foundation.h>
typedef NS_ENUM(NSInteger, Environment) {
Development,
Stage,
Production
};
extern NSString* const EnvironmentProduction;
extern NSString* const EnvironmentStage;
extern NSString* const EnvironmentDevelopment;
@interface PNObjectConfig : NSObject
/**
* gets singleton object.
* @return singleton
*/
/**
*
*
* @param clientIdsForEnvironments
* For example,
* @{ PNObjectConfigDevelopment : @"https://development.it/api/v1",
* PNObjectConfigEnvStage : @"ttps://stage.it/api/v1",
* PNObjectConfigEnvProduction : @"ttps://production.it/api/v1"
* }
*
* @return singleton
*/
+ (instancetype) sharedInstanceForEnvironments:(NSDictionary *) endpointUrlsForEnvironments;
- (void) enableEnvironment:(Environment) env;
@end

View File

@ -0,0 +1,146 @@
//
// PNObjectConfig.m
// Pods
//
// Created by Giuseppe Nucifora on 08/01/16.
//
//
#import "PNObjectConfig.h"
NSString* const EnvironmentProduction = @"PNObjectConfigEnvProduction";
NSString* const EnvironmentStage = @"PNObjectConfigEnvStage";
NSString* const EnvironmentDevelopment = @"PNObjectConfigDevelopment";
@interface PNObjectConfig()
@property (nonatomic, strong) NSMutableDictionary *configuration;
@property (nonatomic) BOOL devEnabled;
@property (nonatomic) BOOL stageEnabled;
@property (nonatomic) BOOL productionEnabled;
@end
@implementation PNObjectConfig
static PNObjectConfig *SINGLETON = nil;
static bool isFirstAccess = YES;
#pragma mark - Public Method
+ (id)sharedInstance
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
isFirstAccess = NO;
SINGLETON = [[super allocWithZone:NULL] init];
});
return SINGLETON;
}
#pragma mark - Life Cycle
+ (instancetype) sharedInstanceForEnvironments:(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 forKey:key];
SINGLETON.devEnabled = YES;
}
},
EnvironmentStage : ^{
NSURL * endpointUrl = [NSURL URLWithString:[endpointUrlsForEnvironments objectForKey:key]];
if (endpointUrl) {
[SINGLETON.configuration setValue:endpointUrl forKey:key];
SINGLETON.stageEnabled = YES;
}
},
EnvironmentProduction : ^{
NSURL * endpointUrl = [NSURL URLWithString:[endpointUrlsForEnvironments objectForKey:key]];
if (endpointUrl) {
[SINGLETON.configuration setValue:endpointUrl forKey:key];
SINGLETON.productionEnabled = YES;
}
}
}[key] ?: ^{
})();
}
NSAssert(SINGLETON.productionEnabled, @"EnvironmentProduction must be valid endpoint url");
NSLog(@"Config : %@",SINGLETON.configuration);
}
return SINGLETON;
}
+ (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 [[PNObjectConfig alloc] init];
}
- (id)mutableCopy
{
return [[PNObjectConfig alloc] init];
}
- (id) init
{
if(SINGLETON){
return SINGLETON;
}
if (isFirstAccess) {
[self doesNotRecognizeSelector:_cmd];
}
self = [super init];
if (self) {
_configuration = [[NSMutableDictionary alloc] init];
}
return self;
}
- (void) enableEnvironment:(Environment) env {
switch (env) {
case Development:{
}
break;
case Stage:{
}
break;
case Production:
default:
break;
}
}
@end

View File

@ -0,0 +1,20 @@
//
// PNObjectSubclassing.h
// Pods
//
// Created by Giuseppe Nucifora on 08/01/16.
//
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@protocol PNObjectSubclassing <NSObject>
@required
+ (NSString *) objectClassName;
+ (NSDictionary *) objcetMapping;
@end

13
Pod/Classes/User/User.h Normal file
View File

@ -0,0 +1,13 @@
//
// User.h
// Pods
//
// Created by Giuseppe Nucifora on 08/01/16.
//
//
#import <PNObject/PNObject.h>
@interface User : PNObject
@end

22
Pod/Classes/User/User.m Normal file
View File

@ -0,0 +1,22 @@
//
// 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