diff options
| author | mo khan <mo@mokhan.ca> | 2013-07-14 15:33:09 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2013-07-14 15:33:09 -0600 |
| commit | 61ca9c941a0fea00b6d51019b9431267163cdac6 (patch) | |
| tree | 947b31250ad0aca796ddafc4b79cd60aa95ae169 | |
| parent | 6ff632a1444a214ba61597ae9e1a034e5f1f6073 (diff) | |
get login working
14 files changed, 586 insertions, 6 deletions
diff --git a/Pods/Pods.xcodeproj/xcuserdata/mo.xcuserdatad/xcschemes/Pods-BlockAlertsAnd-ActionSheets.xcscheme b/Pods/Pods.xcodeproj/xcuserdata/mo.xcuserdatad/xcschemes/Pods-BlockAlertsAnd-ActionSheets.xcscheme new file mode 100644 index 0000000..1296299 --- /dev/null +++ b/Pods/Pods.xcodeproj/xcuserdata/mo.xcuserdatad/xcschemes/Pods-BlockAlertsAnd-ActionSheets.xcscheme @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Scheme + LastUpgradeVersion = "0460" + version = "1.3"> + <BuildAction + parallelizeBuildables = "YES" + buildImplicitDependencies = "YES"> + <BuildActionEntries> + <BuildActionEntry + buildForTesting = "YES" + buildForRunning = "YES" + buildForProfiling = "YES" + buildForArchiving = "YES" + buildForAnalyzing = "YES"> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "0E0FD65313B54B30A90352CB" + BuildableName = "libPods-BlockAlertsAnd-ActionSheets.a" + BlueprintName = "Pods-BlockAlertsAnd-ActionSheets" + ReferencedContainer = "container:Pods.xcodeproj"> + </BuildableReference> + </BuildActionEntry> + </BuildActionEntries> + </BuildAction> + <TestAction + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + shouldUseLaunchSchemeArgsEnv = "YES" + buildConfiguration = "Debug"> + <Testables> + </Testables> + </TestAction> + <LaunchAction + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + launchStyle = "0" + useCustomWorkingDirectory = "NO" + buildConfiguration = "Debug" + ignoresPersistentStateOnLaunch = "NO" + debugDocumentVersioning = "YES" + allowLocationSimulation = "YES"> + <AdditionalOptions> + </AdditionalOptions> + </LaunchAction> + <ProfileAction + shouldUseLaunchSchemeArgsEnv = "YES" + savedToolIdentifier = "" + useCustomWorkingDirectory = "NO" + buildConfiguration = "Release" + debugDocumentVersioning = "YES"> + </ProfileAction> + <AnalyzeAction + buildConfiguration = "Debug"> + </AnalyzeAction> + <ArchiveAction + buildConfiguration = "Release" + revealArchiveInOrganizer = "YES"> + </ArchiveAction> +</Scheme> diff --git a/Pods/Pods.xcodeproj/xcuserdata/mo.xcuserdatad/xcschemes/Pods-BlocksKit.xcscheme b/Pods/Pods.xcodeproj/xcuserdata/mo.xcuserdatad/xcschemes/Pods-BlocksKit.xcscheme new file mode 100644 index 0000000..5755dfe --- /dev/null +++ b/Pods/Pods.xcodeproj/xcuserdata/mo.xcuserdatad/xcschemes/Pods-BlocksKit.xcscheme @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Scheme + LastUpgradeVersion = "0460" + version = "1.3"> + <BuildAction + parallelizeBuildables = "YES" + buildImplicitDependencies = "YES"> + <BuildActionEntries> + <BuildActionEntry + buildForTesting = "YES" + buildForRunning = "YES" + buildForProfiling = "YES" + buildForArchiving = "YES" + buildForAnalyzing = "YES"> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "EC1008539B104E76A2F7FFFA" + BuildableName = "libPods-BlocksKit.a" + BlueprintName = "Pods-BlocksKit" + ReferencedContainer = "container:Pods.xcodeproj"> + </BuildableReference> + </BuildActionEntry> + </BuildActionEntries> + </BuildAction> + <TestAction + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + shouldUseLaunchSchemeArgsEnv = "YES" + buildConfiguration = "Debug"> + <Testables> + </Testables> + </TestAction> + <LaunchAction + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + launchStyle = "0" + useCustomWorkingDirectory = "NO" + buildConfiguration = "Debug" + ignoresPersistentStateOnLaunch = "NO" + debugDocumentVersioning = "YES" + allowLocationSimulation = "YES"> + <AdditionalOptions> + </AdditionalOptions> + </LaunchAction> + <ProfileAction + shouldUseLaunchSchemeArgsEnv = "YES" + savedToolIdentifier = "" + useCustomWorkingDirectory = "NO" + buildConfiguration = "Release" + debugDocumentVersioning = "YES"> + </ProfileAction> + <AnalyzeAction + buildConfiguration = "Debug"> + </AnalyzeAction> + <ArchiveAction + buildConfiguration = "Release" + revealArchiveInOrganizer = "YES"> + </ArchiveAction> +</Scheme> diff --git a/Pods/Pods.xcodeproj/xcuserdata/mo.xcuserdatad/xcschemes/Pods-SVPullToRefresh.xcscheme b/Pods/Pods.xcodeproj/xcuserdata/mo.xcuserdatad/xcschemes/Pods-SVPullToRefresh.xcscheme new file mode 100644 index 0000000..c05d9ce --- /dev/null +++ b/Pods/Pods.xcodeproj/xcuserdata/mo.xcuserdatad/xcschemes/Pods-SVPullToRefresh.xcscheme @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Scheme + LastUpgradeVersion = "0460" + version = "1.3"> + <BuildAction + parallelizeBuildables = "YES" + buildImplicitDependencies = "YES"> + <BuildActionEntries> + <BuildActionEntry + buildForTesting = "YES" + buildForRunning = "YES" + buildForProfiling = "YES" + buildForArchiving = "YES" + buildForAnalyzing = "YES"> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "4460E89DE8284FE18FE2BD48" + BuildableName = "libPods-SVPullToRefresh.a" + BlueprintName = "Pods-SVPullToRefresh" + ReferencedContainer = "container:Pods.xcodeproj"> + </BuildableReference> + </BuildActionEntry> + </BuildActionEntries> + </BuildAction> + <TestAction + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + shouldUseLaunchSchemeArgsEnv = "YES" + buildConfiguration = "Debug"> + <Testables> + </Testables> + </TestAction> + <LaunchAction + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + launchStyle = "0" + useCustomWorkingDirectory = "NO" + buildConfiguration = "Debug" + ignoresPersistentStateOnLaunch = "NO" + debugDocumentVersioning = "YES" + allowLocationSimulation = "YES"> + <AdditionalOptions> + </AdditionalOptions> + </LaunchAction> + <ProfileAction + shouldUseLaunchSchemeArgsEnv = "YES" + savedToolIdentifier = "" + useCustomWorkingDirectory = "NO" + buildConfiguration = "Release" + debugDocumentVersioning = "YES"> + </ProfileAction> + <AnalyzeAction + buildConfiguration = "Debug"> + </AnalyzeAction> + <ArchiveAction + buildConfiguration = "Release" + revealArchiveInOrganizer = "YES"> + </ArchiveAction> +</Scheme> diff --git a/Pods/Pods.xcodeproj/xcuserdata/mo.xcuserdatad/xcschemes/Pods-libffi.xcscheme b/Pods/Pods.xcodeproj/xcuserdata/mo.xcuserdatad/xcschemes/Pods-libffi.xcscheme new file mode 100644 index 0000000..6a9a546 --- /dev/null +++ b/Pods/Pods.xcodeproj/xcuserdata/mo.xcuserdatad/xcschemes/Pods-libffi.xcscheme @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Scheme + LastUpgradeVersion = "0460" + version = "1.3"> + <BuildAction + parallelizeBuildables = "YES" + buildImplicitDependencies = "YES"> + <BuildActionEntries> + <BuildActionEntry + buildForTesting = "YES" + buildForRunning = "YES" + buildForProfiling = "YES" + buildForArchiving = "YES" + buildForAnalyzing = "YES"> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "8C6E42B7209842E5A93EB7B3" + BuildableName = "libPods-libffi.a" + BlueprintName = "Pods-libffi" + ReferencedContainer = "container:Pods.xcodeproj"> + </BuildableReference> + </BuildActionEntry> + </BuildActionEntries> + </BuildAction> + <TestAction + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + shouldUseLaunchSchemeArgsEnv = "YES" + buildConfiguration = "Debug"> + <Testables> + </Testables> + </TestAction> + <LaunchAction + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + launchStyle = "0" + useCustomWorkingDirectory = "NO" + buildConfiguration = "Debug" + ignoresPersistentStateOnLaunch = "NO" + debugDocumentVersioning = "YES" + allowLocationSimulation = "YES"> + <AdditionalOptions> + </AdditionalOptions> + </LaunchAction> + <ProfileAction + shouldUseLaunchSchemeArgsEnv = "YES" + savedToolIdentifier = "" + useCustomWorkingDirectory = "NO" + buildConfiguration = "Release" + debugDocumentVersioning = "YES"> + </ProfileAction> + <AnalyzeAction + buildConfiguration = "Debug"> + </AnalyzeAction> + <ArchiveAction + buildConfiguration = "Release" + revealArchiveInOrganizer = "YES"> + </ArchiveAction> +</Scheme> diff --git a/Pods/Pods.xcodeproj/xcuserdata/mo.xcuserdatad/xcschemes/xcschememanagement.plist b/Pods/Pods.xcodeproj/xcuserdata/mo.xcuserdatad/xcschemes/xcschememanagement.plist index 5bb8194..eba39cc 100644 --- a/Pods/Pods.xcodeproj/xcuserdata/mo.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/Pods/Pods.xcodeproj/xcuserdata/mo.xcuserdatad/xcschemes/xcschememanagement.plist @@ -9,6 +9,16 @@ <key>orderHint</key> <integer>1</integer> </dict> + <key>Pods-BlockAlertsAnd-ActionSheets.xcscheme</key> + <dict> + <key>orderHint</key> + <integer>6</integer> + </dict> + <key>Pods-BlocksKit.xcscheme</key> + <dict> + <key>orderHint</key> + <integer>7</integer> + </dict> <key>Pods-MBProgressHUD.xcscheme</key> <dict> <key>orderHint</key> @@ -19,11 +29,21 @@ <key>orderHint</key> <integer>5</integer> </dict> + <key>Pods-SVPullToRefresh.xcscheme</key> + <dict> + <key>orderHint</key> + <integer>8</integer> + </dict> <key>Pods-TSMessages.xcscheme</key> <dict> <key>orderHint</key> <integer>4</integer> </dict> + <key>Pods-libffi.xcscheme</key> + <dict> + <key>orderHint</key> + <integer>9</integer> + </dict> <key>Pods.xcscheme</key> <dict> <key>orderHint</key> @@ -37,6 +57,11 @@ <key>primary</key> <true/> </dict> + <key>0E0FD65313B54B30A90352CB</key> + <dict> + <key>primary</key> + <true/> + </dict> <key>161441ECEC9D4E86A021D7C9</key> <dict> <key>primary</key> @@ -52,16 +77,46 @@ <key>primary</key> <true/> </dict> + <key>2B978B982DA34D0C8E2CFA33</key> + <dict> + <key>primary</key> + <true/> + </dict> + <key>40E915BCD8264028967AAE4D</key> + <dict> + <key>primary</key> + <true/> + </dict> <key>420FC36D074541F39798DA98</key> <dict> <key>primary</key> <true/> </dict> + <key>4460E89DE8284FE18FE2BD48</key> + <dict> + <key>primary</key> + <true/> + </dict> <key>5A5C34FB827C4A8B8E75E025</key> <dict> <key>primary</key> <true/> </dict> + <key>648C635AFD5F409E86A91E19</key> + <dict> + <key>primary</key> + <true/> + </dict> + <key>6C2B5E0BA805426AAB06E0AC</key> + <dict> + <key>primary</key> + <true/> + </dict> + <key>8C6E42B7209842E5A93EB7B3</key> + <dict> + <key>primary</key> + <true/> + </dict> <key>8FDB4F0606BD4C1894958BA6</key> <dict> <key>primary</key> @@ -87,6 +142,11 @@ <key>primary</key> <true/> </dict> + <key>AE517A633C53422FB1E1DBF4</key> + <dict> + <key>primary</key> + <true/> + </dict> <key>CDA32D12634F442C874A169F</key> <dict> <key>primary</key> @@ -97,6 +157,11 @@ <key>primary</key> <true/> </dict> + <key>EC1008539B104E76A2F7FFFA</key> + <dict> + <key>primary</key> + <true/> + </dict> <key>F24EF3A29A1B4D7A8BF97C22</key> <dict> <key>primary</key> diff --git a/cakeside-ios.xcodeproj/project.pbxproj b/cakeside-ios.xcodeproj/project.pbxproj index e8a45dc..8455199 100644 --- a/cakeside-ios.xcodeproj/project.pbxproj +++ b/cakeside-ios.xcodeproj/project.pbxproj @@ -25,6 +25,8 @@ CDCB348D1793405E00A25F1E /* cakeside_iosTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CDCB348C1793405E00A25F1E /* cakeside_iosTests.m */; }; CDE67AB0179347D400B4742C /* LoginViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = CDE67AAF179347D400B4742C /* LoginViewController.m */; }; CDE67AB2179348EB00B4742C /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDE67AB1179348EB00B4742C /* Security.framework */; }; + CDE67AB617934E4200B4742C /* NSString+Additions.m in Sources */ = {isa = PBXBuildFile; fileRef = CDE67AB517934E4200B4742C /* NSString+Additions.m */; }; + CDE67AC017934E7D00B4742C /* NSDictionary+Additions.m in Sources */ = {isa = PBXBuildFile; fileRef = CDE67ABF17934E7D00B4742C /* NSDictionary+Additions.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -62,6 +64,10 @@ CDE67AAE179347D400B4742C /* LoginViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoginViewController.h; sourceTree = "<group>"; }; CDE67AAF179347D400B4742C /* LoginViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LoginViewController.m; sourceTree = "<group>"; }; CDE67AB1179348EB00B4742C /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; + CDE67AB417934E4200B4742C /* NSString+Additions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+Additions.h"; sourceTree = "<group>"; }; + CDE67AB517934E4200B4742C /* NSString+Additions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+Additions.m"; sourceTree = "<group>"; }; + CDE67ABE17934E7D00B4742C /* NSDictionary+Additions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDictionary+Additions.h"; sourceTree = "<group>"; }; + CDE67ABF17934E7D00B4742C /* NSDictionary+Additions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDictionary+Additions.m"; sourceTree = "<group>"; }; CE65D4B28521438085302B5E /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -127,6 +133,7 @@ CDCB34611793405E00A25F1E /* cakeside-ios */ = { isa = PBXGroup; children = ( + CDE67AB317934E4200B4742C /* utility */, CDE67AAD1793471B00B4742C /* controllers */, CDE67AAC1793471200B4742C /* views */, CDE67AAB179346E800B4742C /* models */, @@ -194,6 +201,17 @@ path = controllers; sourceTree = "<group>"; }; + CDE67AB317934E4200B4742C /* utility */ = { + isa = PBXGroup; + children = ( + CDE67ABE17934E7D00B4742C /* NSDictionary+Additions.h */, + CDE67ABF17934E7D00B4742C /* NSDictionary+Additions.m */, + CDE67AB417934E4200B4742C /* NSString+Additions.h */, + CDE67AB517934E4200B4742C /* NSString+Additions.m */, + ); + path = utility; + sourceTree = "<group>"; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -339,6 +357,8 @@ CDCB34681793405E00A25F1E /* main.m in Sources */, CDCB346C1793405E00A25F1E /* AppDelegate.m in Sources */, CDE67AB0179347D400B4742C /* LoginViewController.m in Sources */, + CDE67AB617934E4200B4742C /* NSString+Additions.m in Sources */, + CDE67AC017934E7D00B4742C /* NSDictionary+Additions.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/cakeside-ios.xcworkspace/xcuserdata/mo.xcuserdatad/UserInterfaceState.xcuserstate b/cakeside-ios.xcworkspace/xcuserdata/mo.xcuserdatad/UserInterfaceState.xcuserstate Binary files differindex 2557aec..e5de6c8 100644 --- a/cakeside-ios.xcworkspace/xcuserdata/mo.xcuserdatad/UserInterfaceState.xcuserstate +++ b/cakeside-ios.xcworkspace/xcuserdata/mo.xcuserdatad/UserInterfaceState.xcuserstate diff --git a/cakeside-ios/cakeside-ios-Prefix.pch b/cakeside-ios/cakeside-ios-Prefix.pch index a765a78..dcf7e28 100644 --- a/cakeside-ios/cakeside-ios-Prefix.pch +++ b/cakeside-ios/cakeside-ios-Prefix.pch @@ -11,7 +11,11 @@ #ifdef __OBJC__ #import <UIKit/UIKit.h> #import <Foundation/Foundation.h> +#import <BlocksKit/BlocksKit.h> +#import "NSString+Additions.h" +#import "NSDictionary+Additions.h" #import "MBProgressHUD.h" +#import "BlockAlertView.h" #import "AppDelegate.h" #import "TSMessage.h" #import "SSKeychain.h" @@ -20,7 +24,7 @@ #endif // URLs -#define HOST @"https://staging.cakeside.com" +#define HOST @"http://localhost:3000" #define URL_LOGIN @"/api/v1/logins" // KeyChain defs @@ -32,4 +36,5 @@ // Other Settings #define HUD_ANIMATION_DURATION 0.4 #define HUD_ANIMATION_DURATION_LONG 1.0 -#define HUD_ANIMATION_DURATION_EXTRALONG 1.6
\ No newline at end of file +#define HUD_ANIMATION_DURATION_EXTRALONG 1.6 +#define OVERLAY_MESSAGE_DURATION 3
\ No newline at end of file diff --git a/cakeside-ios/controllers/LoginViewController.m b/cakeside-ios/controllers/LoginViewController.m index e0f5714..3514005 100644 --- a/cakeside-ios/controllers/LoginViewController.m +++ b/cakeside-ios/controllers/LoginViewController.m @@ -165,10 +165,10 @@ { // successfull login! [SSKeychain setPassword:token forService:KEYCHAIN_API_TOKEN account:KEYCHAIN_ACCOUNT]; - [SSKeychain setPassword:self.email.text forService:KEYCHAIN_USER_NAME account:KEYCHAIN_ACCOUNT]; - [SSKeychain setPassword:self.password.text forService:KEYCHAIN_USER_PASSWORD account:KEYCHAIN_ACCOUNT]; + [SSKeychain setPassword:self.emailTextBox.text forService:KEYCHAIN_USER_NAME account:KEYCHAIN_ACCOUNT]; + [SSKeychain setPassword:self.passwordTextBox.text forService:KEYCHAIN_USER_PASSWORD account:KEYCHAIN_ACCOUNT]; - [self performSegueWithIdentifier:@"gotoMainInterface" sender:nil]; + //[self performSegueWithIdentifier:@"gotoMainInterface" sender:nil]; } } diff --git a/cakeside-ios/en.lproj/LoginViewController.xib b/cakeside-ios/en.lproj/LoginViewController.xib index 935e2df..703bb65 100644 --- a/cakeside-ios/en.lproj/LoginViewController.xib +++ b/cakeside-ios/en.lproj/LoginViewController.xib @@ -250,6 +250,15 @@ </object> <int key="connectionID">70</int> </object> + <object class="IBConnectionRecord"> + <object class="IBCocoaTouchEventConnection" key="connection"> + <string key="label">login:</string> + <reference key="source" ref="830338576"/> + <reference key="destination" ref="372490531"/> + <int key="IBEventType">7</int> + </object> + <int key="connectionID">71</int> + </object> </array> <object class="IBMutableOrderedSet" key="objectRecords"> <array key="orderedObjects"> @@ -697,13 +706,27 @@ <nil key="activeLocalization"/> <dictionary class="NSMutableDictionary" key="localizations"/> <nil key="sourceID"/> - <int key="maxID">70</int> + <int key="maxID">71</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <array class="NSMutableArray" key="referencedPartialClassDescriptions"> <object class="IBPartialClassDescription"> <string key="className">LoginViewController</string> <string key="superclassName">UIViewController</string> + <dictionary class="NSMutableDictionary" key="actions"> + <string key="backgroundTapped:">id</string> + <string key="login:">id</string> + </dictionary> + <dictionary class="NSMutableDictionary" key="actionInfosByName"> + <object class="IBActionInfo" key="backgroundTapped:"> + <string key="name">backgroundTapped:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo" key="login:"> + <string key="name">login:</string> + <string key="candidateClassName">id</string> + </object> + </dictionary> <dictionary class="NSMutableDictionary" key="outlets"> <string key="emailTextBox">UITextField</string> <string key="loginButton">UIButton</string> diff --git a/cakeside-ios/utility/NSDictionary+Additions.h b/cakeside-ios/utility/NSDictionary+Additions.h new file mode 100644 index 0000000..456359b --- /dev/null +++ b/cakeside-ios/utility/NSDictionary+Additions.h @@ -0,0 +1,13 @@ +// +// NSDictionary+NSDictionary_Additions.h +// fastcab-driver +// +// Created by Rick Cotter on 12-03-20. +// Copyright (c) 2012 Assn. All rights reserved. +// + +#import <Foundation/Foundation.h> + +@interface NSDictionary (Additions) +-(id) objectForKey:(NSString *)key defaultValue:(id)defaultValue; +@end diff --git a/cakeside-ios/utility/NSDictionary+Additions.m b/cakeside-ios/utility/NSDictionary+Additions.m new file mode 100644 index 0000000..01f3569 --- /dev/null +++ b/cakeside-ios/utility/NSDictionary+Additions.m @@ -0,0 +1,26 @@ +// +// NSDictionary+NSDictionary_Additions.m +// fastcab-driver +// +// Created by Rick Cotter on 12-03-20. +// Copyright (c) 2012 Assn. All rights reserved. +// + +#import "NSDictionary+Additions.h" + +@implementation NSDictionary (Additions) + +-(id) objectForKey:(NSString *)key defaultValue:(id)defaultValue { + id value = [self objectForKey:key]; + if (!value) { + return defaultValue; + } + + if (value == [NSNull null]) { + return defaultValue; + } + + return value; +} + +@end diff --git a/cakeside-ios/utility/NSString+Additions.h b/cakeside-ios/utility/NSString+Additions.h new file mode 100644 index 0000000..a7f8a75 --- /dev/null +++ b/cakeside-ios/utility/NSString+Additions.h @@ -0,0 +1,33 @@ +// +// NSString+Additions.h +// Cardinal +// +// Created by Cory Smith on 10-03-28. +// Copyright 2010 Assn. All rights reserved. +// + +@interface NSString (md5) + ++ (NSString *) md5:(NSString *)str; + +@end + +@interface NSString (Assn) +- (NSString *)trim; +- (BOOL)isEmpty; +- (BOOL)startsWith:(NSString *)starting; +- (BOOL)endsWith:(NSString *)ending; +- (BOOL)contains:(NSString *)text; +- (NSString *)urlEncode; +- (NSString *)replace:(NSString *)find with:(NSString *)replacement; +- (NSString *)replaceAll:(NSArray *)keys with:(NSArray *)values; + +// Replace newlines with <br /> tags. +- (NSString *)stringWithNewLinesAsBRs; + +- (NSString *)sanitizeForHTMLOutput; + ++ (NSString *)generateUUID; + +@end + diff --git a/cakeside-ios/utility/NSString+Additions.m b/cakeside-ios/utility/NSString+Additions.m new file mode 100644 index 0000000..57c782c --- /dev/null +++ b/cakeside-ios/utility/NSString+Additions.m @@ -0,0 +1,159 @@ +// +// NSString+Additions.m +// Cardinal +// +// Created by Cory Smith on 10-03-28. +// Copyright 2010 Assn. All rights reserved. +// + +#import "NSString+Additions.h" + + +#import <CommonCrypto/CommonDigest.h> + +@implementation NSString (md5) + ++ (NSString *) md5:(NSString *)str { + const char *cStr = [str UTF8String]; + unsigned char result[16]; + CC_MD5( cStr, strlen(cStr), result ); + return [NSString stringWithFormat: + @"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X", + result[0], result[1], result[2], result[3], + result[4], result[5], result[6], result[7], + result[8], result[9], result[10], result[11], + result[12], result[13], result[14], result[15] + ]; +} + +@end + +@implementation NSString (Assn) + +- (NSString *)trim { + return [self stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; +} + +- (BOOL)isEmpty { + return [[self trim] isEqualToString:@""]; +} + +- (BOOL)endsWith:(NSString *)ending { + + int indexToCheck = [self length] - [ending length]; + + if(indexToCheck >= 0) + return [[self substringFromIndex:indexToCheck] isEqualToString:ending]; + + return NO; +} + +- (BOOL)startsWith:(NSString *)starting { + if([starting isEmpty] || [starting length] > self.length) + return NO; + + return [[self substringToIndex:[starting length]] isEqualToString:starting]; +} + +- (NSString *)replace:(NSString *)find with:(NSString *)replacement { + return [self stringByReplacingOccurrencesOfString:find withString:replacement]; +} + + +- (NSString *)replaceAll:(NSArray *)keys with:(NSArray *)values { + + NSMutableString *s = [NSMutableString stringWithString:self]; + + for (int i = 0; i < keys.count; i++) { + [s replaceOccurrencesOfString:[keys objectAtIndex:i] + withString:[values objectAtIndex:i] + options:NSLiteralSearch + range:NSMakeRange(0, [s length])]; + } + + return s; +} + + +- (BOOL)contains:(NSString *)text { + NSRange range = [[self lowercaseString] rangeOfString:[text lowercaseString]]; + return range.location != NSNotFound; +} + +- (NSString *)urlEncode +{ + NSString *result = (__bridge NSString *) CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (__bridge CFStringRef)self, NULL, CFSTR(":/?#[]@!$&’()*+,;="), kCFStringEncodingUTF8); + return result; +} + +- (NSString *)stringWithNewLinesAsBRs { + + // Strange New lines: + // Next Line, U+0085 + // Form Feed, U+000C + // Line Separator, U+2028 + // Paragraph Separator, U+2029 + + // Scanner + NSScanner *scanner = [[NSScanner alloc] initWithString:self]; + [scanner setCharactersToBeSkipped:nil]; + NSMutableString *result = [[NSMutableString alloc] init]; + NSString *temp; + NSCharacterSet *newLineCharacters = [NSCharacterSet characterSetWithCharactersInString: + [NSString stringWithFormat:@"\n\r"]]; + // Scan + do { + + // Get non new line characters + temp = nil; + [scanner scanUpToCharactersFromSet:newLineCharacters intoString:&temp]; + if (temp) [result appendString:temp]; + temp = nil; + + // Add <br /> s + if ([scanner scanString:@"\r\n" intoString:nil]) { + + // Combine \r\n into just 1 <br /> + [result appendString:@"<br />"]; + + } else if ([scanner scanCharactersFromSet:newLineCharacters intoString:&temp]) { + + // Scan other new line characters and add <br /> s + if (temp) { + for (NSUInteger i = 0; i < temp.length; i++) { + [result appendString:@"<br />"]; + } + } + + } + + } while (![scanner isAtEnd]); + + // Cleanup & return + NSString *retString = [NSString stringWithString:result]; + + // Return + return retString; + +} + + +- (NSString *)sanitizeForHTMLOutput +{ + NSString *result = self; + if (!result) { result = @""; } + result = [result trim]; + result = [result stringWithNewLinesAsBRs]; + return result; +} + ++ (NSString *)generateUUID +{ + CFUUIDRef newUniqueId = CFUUIDCreate(kCFAllocatorDefault); + NSString * uuidString = (__bridge_transfer NSString*)CFUUIDCreateString(kCFAllocatorDefault, newUniqueId); + CFRelease(newUniqueId); + + return uuidString; +} + +@end |
