appjam 0.1.8.6 → 0.1.8.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. data/lib/appjam.rb +1 -1
  2. data/lib/appjam/generators/blank.rb +133 -0
  3. data/lib/appjam/generators/help.rb +5 -3
  4. data/lib/appjam/generators/templates/blank/EiffelApplication.xcodeproj/project.pbxproj +855 -0
  5. data/lib/appjam/generators/templates/blank/EiffelApplication.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  6. data/lib/appjam/generators/templates/blank/EiffelApplication.xcodeproj/project.xcworkspace/xcuserdata/eiffel.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  7. data/lib/appjam/generators/templates/blank/EiffelApplication.xcodeproj/xcuserdata/eiffel.xcuserdatad/xcschemes/EiffelApplication.xcscheme +96 -0
  8. data/lib/appjam/generators/templates/blank/EiffelApplication.xcodeproj/xcuserdata/eiffel.xcuserdatad/xcschemes/xcschememanagement.plist +27 -0
  9. data/lib/appjam/generators/templates/blank/EiffelApplication/AppDelegate.h.tt +22 -0
  10. data/lib/appjam/generators/templates/blank/EiffelApplication/AppDelegate.m.tt +156 -0
  11. data/lib/appjam/generators/templates/blank/EiffelApplication/EiffelApplication-Info.plist +45 -0
  12. data/lib/appjam/generators/templates/blank/EiffelApplication/EiffelApplication-Prefix.pch.tt +30 -0
  13. data/lib/appjam/generators/templates/blank/EiffelApplication/en.lproj/InfoPlist.strings +2 -0
  14. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFHTTPClient.h +636 -0
  15. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFHTTPClient.m +1359 -0
  16. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFHTTPRequestOperation.h +133 -0
  17. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFHTTPRequestOperation.m +318 -0
  18. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFImageRequestOperation.h +108 -0
  19. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFImageRequestOperation.m +234 -0
  20. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFJSONRequestOperation.h +71 -0
  21. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFJSONRequestOperation.m +142 -0
  22. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFNetworkActivityIndicatorManager.h +75 -0
  23. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFNetworkActivityIndicatorManager.m +145 -0
  24. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFNetworking.h +43 -0
  25. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFPropertyListRequestOperation.h +68 -0
  26. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFPropertyListRequestOperation.m +142 -0
  27. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFURLConnectionOperation.h +379 -0
  28. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFURLConnectionOperation.m +818 -0
  29. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFXMLRequestOperation.h +89 -0
  30. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/AFXMLRequestOperation.m +166 -0
  31. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/UIImageView+AFNetworking.h +78 -0
  32. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/AFNetworking/UIImageView+AFNetworking.m +184 -0
  33. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/JSONKit/JSONKit.h +251 -0
  34. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/JSONKit/JSONKit.m +3067 -0
  35. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/fmdb/FMDatabase.h +155 -0
  36. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/fmdb/FMDatabase.m +1162 -0
  37. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/fmdb/FMDatabaseAdditions.h +37 -0
  38. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/fmdb/FMDatabaseAdditions.m +163 -0
  39. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/fmdb/FMDatabasePool.h +75 -0
  40. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/fmdb/FMDatabasePool.m +244 -0
  41. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/fmdb/FMDatabaseQueue.h +38 -0
  42. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/fmdb/FMDatabaseQueue.m +176 -0
  43. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/fmdb/FMResultSet.h +104 -0
  44. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/frameworks/fmdb/FMResultSet.m +413 -0
  45. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/EGOCache/EGOCache.h +78 -0
  46. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/EGOCache/EGOCache.m +370 -0
  47. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/DDASLLogger.h +41 -0
  48. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/DDASLLogger.m +99 -0
  49. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/DDAbstractDatabaseLogger.h +102 -0
  50. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/DDAbstractDatabaseLogger.m +727 -0
  51. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/DDFileLogger.h +334 -0
  52. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/DDFileLogger.m +1353 -0
  53. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/DDLog.h +601 -0
  54. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/DDLog.m +1083 -0
  55. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/DDTTYLogger.h +167 -0
  56. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/DDTTYLogger.m +1479 -0
  57. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/Extensions/ContextFilterLogFormatter.h +65 -0
  58. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/Extensions/ContextFilterLogFormatter.m +191 -0
  59. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/Extensions/DispatchQueueLogFormatter.h +116 -0
  60. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Lumberjack/Extensions/DispatchQueueLogFormatter.m +251 -0
  61. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/ObjectiveMixin/Mixin.h +33 -0
  62. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/ObjectiveMixin/Mixin.m +122 -0
  63. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Underscore/USArrayWrapper.h +72 -0
  64. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Underscore/USArrayWrapper.m +305 -0
  65. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Underscore/USConstants.h +38 -0
  66. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Underscore/USDictionaryWrapper.h +57 -0
  67. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Underscore/USDictionaryWrapper.m +188 -0
  68. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Underscore/Underscore+Functional.h +89 -0
  69. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Underscore/Underscore+Functional.m +261 -0
  70. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Underscore/Underscore-Prefix.pch +7 -0
  71. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Underscore/Underscore.h +50 -0
  72. data/lib/appjam/generators/templates/blank/EiffelApplication/libs/toolkit/Underscore/Underscore.m +100 -0
  73. data/lib/appjam/generators/templates/blank/EiffelApplication/main.m.tt +18 -0
  74. data/lib/appjam/generators/templates/blank/EiffelApplicationTests/EiffelApplicationTests-Info.plist +22 -0
  75. data/lib/appjam/generators/templates/blank/EiffelApplicationTests/EiffelApplicationTests.h.tt +13 -0
  76. data/lib/appjam/generators/templates/blank/EiffelApplicationTests/EiffelApplicationTests.m.tt +32 -0
  77. data/lib/appjam/generators/templates/blank/EiffelApplicationTests/en.lproj/InfoPlist.strings +2 -0
  78. data/lib/appjam/generators/templates/resources/Default-568h@2x.png +0 -0
  79. data/lib/appjam/generators/templates/resources/Default.png +0 -0
  80. data/lib/appjam/generators/templates/resources/Default@2x.png +0 -0
  81. data/lib/appjam/generators/templates/resources/contents.tt +4 -0
  82. data/lib/appjam/version.rb +1 -1
  83. metadata +462 -326
  84. data/test/helper.rb +0 -132
  85. data/test/test_model_generator.rb +0 -28
  86. data/test/test_project_generator.rb +0 -38
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Workspace
3
+ version = "1.0">
4
+ <FileRef
5
+ location = "self:EiffelApplication.xcodeproj">
6
+ </FileRef>
7
+ </Workspace>
@@ -0,0 +1,96 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Scheme
3
+ LastUpgradeVersion = "0460"
4
+ version = "1.3">
5
+ <BuildAction
6
+ parallelizeBuildables = "YES"
7
+ buildImplicitDependencies = "YES">
8
+ <BuildActionEntries>
9
+ <BuildActionEntry
10
+ buildForTesting = "YES"
11
+ buildForRunning = "YES"
12
+ buildForProfiling = "YES"
13
+ buildForArchiving = "YES"
14
+ buildForAnalyzing = "YES">
15
+ <BuildableReference
16
+ BuildableIdentifier = "primary"
17
+ BlueprintIdentifier = "C52561BC1705AD5200AC76A2"
18
+ BuildableName = "EiffelApplication.app"
19
+ BlueprintName = "EiffelApplication"
20
+ ReferencedContainer = "container:EiffelApplication.xcodeproj">
21
+ </BuildableReference>
22
+ </BuildActionEntry>
23
+ </BuildActionEntries>
24
+ </BuildAction>
25
+ <TestAction
26
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
27
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
28
+ shouldUseLaunchSchemeArgsEnv = "YES"
29
+ buildConfiguration = "Debug">
30
+ <Testables>
31
+ <TestableReference
32
+ skipped = "NO">
33
+ <BuildableReference
34
+ BuildableIdentifier = "primary"
35
+ BlueprintIdentifier = "C52561E11705AD5200AC76A2"
36
+ BuildableName = "EiffelApplicationTests.octest"
37
+ BlueprintName = "EiffelApplicationTests"
38
+ ReferencedContainer = "container:EiffelApplication.xcodeproj">
39
+ </BuildableReference>
40
+ </TestableReference>
41
+ </Testables>
42
+ <MacroExpansion>
43
+ <BuildableReference
44
+ BuildableIdentifier = "primary"
45
+ BlueprintIdentifier = "C52561BC1705AD5200AC76A2"
46
+ BuildableName = "EiffelApplication.app"
47
+ BlueprintName = "EiffelApplication"
48
+ ReferencedContainer = "container:EiffelApplication.xcodeproj">
49
+ </BuildableReference>
50
+ </MacroExpansion>
51
+ </TestAction>
52
+ <LaunchAction
53
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
54
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
55
+ launchStyle = "0"
56
+ useCustomWorkingDirectory = "NO"
57
+ buildConfiguration = "Debug"
58
+ ignoresPersistentStateOnLaunch = "NO"
59
+ debugDocumentVersioning = "YES"
60
+ allowLocationSimulation = "YES">
61
+ <BuildableProductRunnable>
62
+ <BuildableReference
63
+ BuildableIdentifier = "primary"
64
+ BlueprintIdentifier = "C52561BC1705AD5200AC76A2"
65
+ BuildableName = "EiffelApplication.app"
66
+ BlueprintName = "EiffelApplication"
67
+ ReferencedContainer = "container:EiffelApplication.xcodeproj">
68
+ </BuildableReference>
69
+ </BuildableProductRunnable>
70
+ <AdditionalOptions>
71
+ </AdditionalOptions>
72
+ </LaunchAction>
73
+ <ProfileAction
74
+ shouldUseLaunchSchemeArgsEnv = "YES"
75
+ savedToolIdentifier = ""
76
+ useCustomWorkingDirectory = "NO"
77
+ buildConfiguration = "Release"
78
+ debugDocumentVersioning = "YES">
79
+ <BuildableProductRunnable>
80
+ <BuildableReference
81
+ BuildableIdentifier = "primary"
82
+ BlueprintIdentifier = "C52561BC1705AD5200AC76A2"
83
+ BuildableName = "EiffelApplication.app"
84
+ BlueprintName = "EiffelApplication"
85
+ ReferencedContainer = "container:EiffelApplication.xcodeproj">
86
+ </BuildableReference>
87
+ </BuildableProductRunnable>
88
+ </ProfileAction>
89
+ <AnalyzeAction
90
+ buildConfiguration = "Debug">
91
+ </AnalyzeAction>
92
+ <ArchiveAction
93
+ buildConfiguration = "Release"
94
+ revealArchiveInOrganizer = "YES">
95
+ </ArchiveAction>
96
+ </Scheme>
@@ -0,0 +1,27 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>SchemeUserState</key>
6
+ <dict>
7
+ <key>EiffelApplication.xcscheme</key>
8
+ <dict>
9
+ <key>orderHint</key>
10
+ <integer>0</integer>
11
+ </dict>
12
+ </dict>
13
+ <key>SuppressBuildableAutocreation</key>
14
+ <dict>
15
+ <key>C52561BC1705AD5200AC76A2</key>
16
+ <dict>
17
+ <key>primary</key>
18
+ <true/>
19
+ </dict>
20
+ <key>C52561E11705AD5200AC76A2</key>
21
+ <dict>
22
+ <key>primary</key>
23
+ <true/>
24
+ </dict>
25
+ </dict>
26
+ </dict>
27
+ </plist>
@@ -0,0 +1,22 @@
1
+ //
2
+ // AppDelegate.h
3
+ // EiffelApplication
4
+ //
5
+ // Created by eiffel on 3/29/13.
6
+ // Copyright (c) 2013 likenote. All rights reserved.
7
+ //
8
+
9
+ #import <UIKit/UIKit.h>
10
+
11
+ @interface AppDelegate : UIResponder <UIApplicationDelegate>
12
+
13
+ @property (strong, nonatomic) UIWindow *window;
14
+
15
+ @property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext;
16
+ @property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel;
17
+ @property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator;
18
+
19
+ - (void)saveContext;
20
+ - (NSURL *)applicationDocumentsDirectory;
21
+
22
+ @end
@@ -0,0 +1,156 @@
1
+ //
2
+ // AppDelegate.m
3
+ // EiffelApplication
4
+ //
5
+ // Created by eiffel on 3/29/13.
6
+ // Copyright (c) 2013 likenote. All rights reserved.
7
+ //
8
+
9
+ #import "AppDelegate.h"
10
+
11
+ @implementation AppDelegate
12
+
13
+ static const int ddLogLevel = LOG_LEVEL_VERBOSE;
14
+
15
+ @synthesize managedObjectContext = _managedObjectContext;
16
+ @synthesize managedObjectModel = _managedObjectModel;
17
+ @synthesize persistentStoreCoordinator = _persistentStoreCoordinator;
18
+
19
+ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
20
+ {
21
+ [DDLog addLogger:[DDASLLogger sharedInstance]];
22
+ [DDLog addLogger:[DDTTYLogger sharedInstance]];
23
+
24
+ DDLogVerbose(@"Start App");
25
+ DLog(@"didFinishLaunching...");
26
+ self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
27
+ // Override point for customization after application launch.
28
+ self.window.backgroundColor = [UIColor whiteColor];
29
+ [self.window makeKeyAndVisible];
30
+ return YES;
31
+ }
32
+
33
+ - (void)applicationWillResignActive:(UIApplication *)application
34
+ {
35
+ // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
36
+ // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
37
+ }
38
+
39
+ - (void)applicationDidEnterBackground:(UIApplication *)application
40
+ {
41
+ // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
42
+ // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
43
+ }
44
+
45
+ - (void)applicationWillEnterForeground:(UIApplication *)application
46
+ {
47
+ // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
48
+ }
49
+
50
+ - (void)applicationDidBecomeActive:(UIApplication *)application
51
+ {
52
+ // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
53
+ }
54
+
55
+ - (void)applicationWillTerminate:(UIApplication *)application
56
+ {
57
+ // Saves changes in the application's managed object context before the application terminates.
58
+ [self saveContext];
59
+ }
60
+
61
+ - (void)saveContext
62
+ {
63
+ NSError *error = nil;
64
+ NSManagedObjectContext *managedObjectContext = self.managedObjectContext;
65
+ if (managedObjectContext != nil) {
66
+ if ([managedObjectContext hasChanges] && ![managedObjectContext save:&error]) {
67
+ // Replace this implementation with code to handle the error appropriately.
68
+ // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
69
+ NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
70
+ abort();
71
+ }
72
+ }
73
+ }
74
+
75
+ #pragma mark - Core Data stack
76
+
77
+ // Returns the managed object context for the application.
78
+ // If the context doesn't already exist, it is created and bound to the persistent store coordinator for the application.
79
+ - (NSManagedObjectContext *)managedObjectContext
80
+ {
81
+ if (_managedObjectContext != nil) {
82
+ return _managedObjectContext;
83
+ }
84
+
85
+ NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator];
86
+ if (coordinator != nil) {
87
+ _managedObjectContext = [[NSManagedObjectContext alloc] init];
88
+ [_managedObjectContext setPersistentStoreCoordinator:coordinator];
89
+ }
90
+ return _managedObjectContext;
91
+ }
92
+
93
+ // Returns the managed object model for the application.
94
+ // If the model doesn't already exist, it is created from the application's model.
95
+ - (NSManagedObjectModel *)managedObjectModel
96
+ {
97
+ if (_managedObjectModel != nil) {
98
+ return _managedObjectModel;
99
+ }
100
+ NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"EiffelApplication" withExtension:@"momd"];
101
+ _managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
102
+ return _managedObjectModel;
103
+ }
104
+
105
+ // Returns the persistent store coordinator for the application.
106
+ // If the coordinator doesn't already exist, it is created and the application's store added to it.
107
+ - (NSPersistentStoreCoordinator *)persistentStoreCoordinator
108
+ {
109
+ if (_persistentStoreCoordinator != nil) {
110
+ return _persistentStoreCoordinator;
111
+ }
112
+
113
+ NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"EiffelApplication.sqlite"];
114
+
115
+ NSError *error = nil;
116
+ _persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
117
+ if (![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error]) {
118
+ /*
119
+ Replace this implementation with code to handle the error appropriately.
120
+
121
+ abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
122
+
123
+ Typical reasons for an error here include:
124
+ * The persistent store is not accessible;
125
+ * The schema for the persistent store is incompatible with current managed object model.
126
+ Check the error message to determine what the actual problem was.
127
+
128
+
129
+ If the persistent store is not accessible, there is typically something wrong with the file path. Often, a file URL is pointing into the application's resources directory instead of a writeable directory.
130
+
131
+ If you encounter schema incompatibility errors during development, you can reduce their frequency by:
132
+ * Simply deleting the existing store:
133
+ [[NSFileManager defaultManager] removeItemAtURL:storeURL error:nil]
134
+
135
+ * Performing automatic lightweight migration by passing the following dictionary as the options parameter:
136
+ @{NSMigratePersistentStoresAutomaticallyOption:@YES, NSInferMappingModelAutomaticallyOption:@YES}
137
+
138
+ Lightweight migration will only work for a limited set of schema changes; consult "Core Data Model Versioning and Data Migration Programming Guide" for details.
139
+
140
+ */
141
+ NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
142
+ abort();
143
+ }
144
+
145
+ return _persistentStoreCoordinator;
146
+ }
147
+
148
+ #pragma mark - Application's Documents directory
149
+
150
+ // Returns the URL to the application's Documents directory.
151
+ - (NSURL *)applicationDocumentsDirectory
152
+ {
153
+ return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
154
+ }
155
+
156
+ @end
@@ -0,0 +1,45 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>CFBundleDevelopmentRegion</key>
6
+ <string>en</string>
7
+ <key>CFBundleDisplayName</key>
8
+ <string>${PRODUCT_NAME}</string>
9
+ <key>CFBundleExecutable</key>
10
+ <string>${EXECUTABLE_NAME}</string>
11
+ <key>CFBundleIdentifier</key>
12
+ <string>com.likenote.ios.EiffelApplication</string>
13
+ <key>CFBundleInfoDictionaryVersion</key>
14
+ <string>6.0</string>
15
+ <key>CFBundleName</key>
16
+ <string>${PRODUCT_NAME}</string>
17
+ <key>CFBundlePackageType</key>
18
+ <string>APPL</string>
19
+ <key>CFBundleShortVersionString</key>
20
+ <string>1.0</string>
21
+ <key>CFBundleSignature</key>
22
+ <string>????</string>
23
+ <key>CFBundleVersion</key>
24
+ <string>1.0</string>
25
+ <key>LSRequiresIPhoneOS</key>
26
+ <true/>
27
+ <key>UIRequiredDeviceCapabilities</key>
28
+ <array>
29
+ <string>armv7</string>
30
+ </array>
31
+ <key>UISupportedInterfaceOrientations</key>
32
+ <array>
33
+ <string>UIInterfaceOrientationPortrait</string>
34
+ <string>UIInterfaceOrientationLandscapeLeft</string>
35
+ <string>UIInterfaceOrientationLandscapeRight</string>
36
+ </array>
37
+ <key>UISupportedInterfaceOrientations~ipad</key>
38
+ <array>
39
+ <string>UIInterfaceOrientationPortrait</string>
40
+ <string>UIInterfaceOrientationPortraitUpsideDown</string>
41
+ <string>UIInterfaceOrientationLandscapeLeft</string>
42
+ <string>UIInterfaceOrientationLandscapeRight</string>
43
+ </array>
44
+ </dict>
45
+ </plist>
@@ -0,0 +1,30 @@
1
+ //
2
+ // Prefix header for all source files of the 'EiffelApplication' target in the 'EiffelApplication' project
3
+ //
4
+
5
+ #import <Availability.h>
6
+ #import <SystemConfiguration/SystemConfiguration.h>
7
+ #import <MobileCoreServices/MobileCoreServices.h>
8
+ #import "DDLog.h"
9
+ #import "DDASLLogger.h"
10
+ #import "DDFileLogger.h"
11
+ #import "DDTTYLogger.h"
12
+
13
+ #ifndef __IPHONE_3_0
14
+ #warning "This project uses features only available in iOS SDK 3.0 and later."
15
+ #endif
16
+
17
+ #ifdef DEBUG
18
+ # define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
19
+ #else
20
+ # define DLog(...)
21
+ #endif
22
+
23
+ // ALog always displays output regardless of the DEBUG setting
24
+ #define ALog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
25
+
26
+ #ifdef __OBJC__
27
+ #import <UIKit/UIKit.h>
28
+ #import <Foundation/Foundation.h>
29
+ #import <CoreData/CoreData.h>
30
+ #endif
@@ -0,0 +1,2 @@
1
+ /* Localized versions of Info.plist keys */
2
+
@@ -0,0 +1,636 @@
1
+ // AFHTTPClient.h
2
+ //
3
+ // Copyright (c) 2011 Gowalla (http://gowalla.com/)
4
+ //
5
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ // of this software and associated documentation files (the "Software"), to deal
7
+ // in the Software without restriction, including without limitation the rights
8
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ // copies of the Software, and to permit persons to whom the Software is
10
+ // furnished to do so, subject to the following conditions:
11
+ //
12
+ // The above copyright notice and this permission notice shall be included in
13
+ // all copies or substantial portions of the Software.
14
+ //
15
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ // THE SOFTWARE.
22
+
23
+ #import <Foundation/Foundation.h>
24
+ #import "AFURLConnectionOperation.h"
25
+
26
+ #import <Availability.h>
27
+
28
+ /**
29
+ `AFHTTPClient` captures the common patterns of communicating with an web application over HTTP. It encapsulates information like base URL, authorization credentials, and HTTP headers, and uses them to construct and manage the execution of HTTP request operations.
30
+
31
+ ## Automatic Content Parsing
32
+
33
+ Instances of `AFHTTPClient` may specify which types of requests it expects and should handle by registering HTTP operation classes for automatic parsing. Registered classes will determine whether they can handle a particular request, and then construct a request operation accordingly in `enqueueHTTPRequestOperationWithRequest:success:failure`.
34
+
35
+ ## Subclassing Notes
36
+
37
+ In most cases, one should create an `AFHTTPClient` subclass for each website or web application that your application communicates with. It is often useful, also, to define a class method that returns a singleton shared HTTP client in each subclass, that persists authentication credentials and other configuration across the entire application.
38
+
39
+ ## Methods to Override
40
+
41
+ To change the behavior of all url request construction for an `AFHTTPClient` subclass, override `requestWithMethod:path:parameters`.
42
+
43
+ To change the behavior of all request operation construction for an `AFHTTPClient` subclass, override `HTTPRequestOperationWithRequest:success:failure`.
44
+
45
+ ## Default Headers
46
+
47
+ By default, `AFHTTPClient` sets the following HTTP headers:
48
+
49
+ - `Accept-Language: (comma-delimited preferred languages), en-us;q=0.8`
50
+ - `User-Agent: (generated user agent)`
51
+
52
+ You can override these HTTP headers or define new ones using `setDefaultHeader:value:`.
53
+
54
+ ## URL Construction Using Relative Paths
55
+
56
+ Both `-requestWithMethod:path:parameters:` and `-multipartFormRequestWithMethod:path:parameters:constructingBodyWithBlock:` construct URLs from the path relative to the `-baseURL`, using `NSURL +URLWithString:relativeToURL:`. Below are a few examples of how `baseURL` and relative paths interact:
57
+
58
+ NSURL *baseURL = [NSURL URLWithString:@"http://example.com/v1/"];
59
+ [NSURL URLWithString:@"foo" relativeToURL:baseURL]; // http://example.com/v1/foo
60
+ [NSURL URLWithString:@"foo?bar=baz" relativeToURL:baseURL]; // http://example.com/v1/foo?bar=baz
61
+ [NSURL URLWithString:@"/foo" relativeToURL:baseURL]; // http://example.com/foo
62
+ [NSURL URLWithString:@"foo/" relativeToURL:baseURL]; // http://example.com/v1/foo
63
+ [NSURL URLWithString:@"/foo/" relativeToURL:baseURL]; // http://example.com/foo/
64
+ [NSURL URLWithString:@"http://example2.com/" relativeToURL:baseURL]; // http://example2.com/
65
+
66
+ Also important to note is that a trailing slash will be added to any `baseURL` without one, which would otherwise cause unexpected behavior when constructing URLs using paths without a leading slash.
67
+
68
+ ## NSCoding / NSCopying Conformance
69
+
70
+ `AFHTTPClient` conforms to the `NSCoding` and `NSCopying` protocols, allowing operations to be archived to disk, and copied in memory, respectively. There are a few minor caveats to keep in mind, however:
71
+
72
+ - Archives and copies of HTTP clients will be initialized with an empty operation queue.
73
+ - NSCoding cannot serialize / deserialize block properties, so an archive of an HTTP client will not include any reachability callback block that may be set.
74
+ */
75
+
76
+ #ifdef _SYSTEMCONFIGURATION_H
77
+ typedef enum {
78
+ AFNetworkReachabilityStatusUnknown = -1,
79
+ AFNetworkReachabilityStatusNotReachable = 0,
80
+ AFNetworkReachabilityStatusReachableViaWWAN = 1,
81
+ AFNetworkReachabilityStatusReachableViaWiFi = 2,
82
+ } AFNetworkReachabilityStatus;
83
+ #else
84
+ #warning SystemConfiguration framework not found in project, or not included in precompiled header. Network reachability functionality will not be available.
85
+ #endif
86
+
87
+ #ifndef __UTTYPE__
88
+ #if __IPHONE_OS_VERSION_MIN_REQUIRED
89
+ #warning MobileCoreServices framework not found in project, or not included in precompiled header. Automatic MIME type detection when uploading files in multipart requests will not be available.
90
+ #else
91
+ #warning CoreServices framework not found in project, or not included in precompiled header. Automatic MIME type detection when uploading files in multipart requests will not be available.
92
+ #endif
93
+ #endif
94
+
95
+ typedef enum {
96
+ AFFormURLParameterEncoding,
97
+ AFJSONParameterEncoding,
98
+ AFPropertyListParameterEncoding,
99
+ } AFHTTPClientParameterEncoding;
100
+
101
+ @class AFHTTPRequestOperation;
102
+ @protocol AFMultipartFormData;
103
+
104
+ @interface AFHTTPClient : NSObject <NSCoding, NSCopying>
105
+
106
+ ///---------------------------------------
107
+ /// @name Accessing HTTP Client Properties
108
+ ///---------------------------------------
109
+
110
+ /**
111
+ The url used as the base for paths specified in methods such as `getPath:parameters:success:failure`
112
+ */
113
+ @property (readonly, nonatomic, strong) NSURL *baseURL;
114
+
115
+ /**
116
+ The string encoding used in constructing url requests. This is `NSUTF8StringEncoding` by default.
117
+ */
118
+ @property (nonatomic, assign) NSStringEncoding stringEncoding;
119
+
120
+ /**
121
+ The `AFHTTPClientParameterEncoding` value corresponding to how parameters are encoded into a request body. This is `AFFormURLParameterEncoding` by default.
122
+
123
+ @warning Some nested parameter structures, such as a keyed array of hashes containing inconsistent keys (i.e. `@{@"": @[@{@"a" : @(1)}, @{@"b" : @(2)}]}`), cannot be unambiguously represented in query strings. It is strongly recommended that an unambiguous encoding, such as `AFJSONParameterEncoding`, is used when posting complicated or nondeterministic parameter structures.
124
+ */
125
+ @property (nonatomic, assign) AFHTTPClientParameterEncoding parameterEncoding;
126
+
127
+ /**
128
+ The operation queue which manages operations enqueued by the HTTP client.
129
+ */
130
+ @property (readonly, nonatomic, strong) NSOperationQueue *operationQueue;
131
+
132
+ /**
133
+ The reachability status from the device to the current `baseURL` of the `AFHTTPClient`.
134
+
135
+ @warning This property requires the `SystemConfiguration` framework. Add it in the active target's "Link Binary With Library" build phase, and add `#import <SystemConfiguration/SystemConfiguration.h>` to the header prefix of the project (`Prefix.pch`).
136
+ */
137
+ #ifdef _SYSTEMCONFIGURATION_H
138
+ @property (readonly, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus;
139
+ #endif
140
+
141
+ /**
142
+ Default SSL pinning mode for each `AFHTTPRequestOperation` which will be enqueued with `enqueueHTTPRequestOperation:`.
143
+ */
144
+ #ifdef _AFNETWORKING_PIN_SSL_CERTIFICATES_
145
+ @property (nonatomic, assign) AFURLConnectionOperationSSLPinningMode defaultSSLPinningMode;
146
+ #endif
147
+
148
+ ///---------------------------------------------
149
+ /// @name Creating and Initializing HTTP Clients
150
+ ///---------------------------------------------
151
+
152
+ /**
153
+ Creates and initializes an `AFHTTPClient` object with the specified base URL.
154
+
155
+ @param url The base URL for the HTTP client. This argument must not be `nil`.
156
+
157
+ @return The newly-initialized HTTP client
158
+ */
159
+ + (instancetype)clientWithBaseURL:(NSURL *)url;
160
+
161
+ /**
162
+ Initializes an `AFHTTPClient` object with the specified base URL.
163
+
164
+ @param url The base URL for the HTTP client. This argument must not be `nil`.
165
+
166
+ @discussion This is the designated initializer.
167
+
168
+ @return The newly-initialized HTTP client
169
+ */
170
+ - (id)initWithBaseURL:(NSURL *)url;
171
+
172
+ ///-----------------------------------
173
+ /// @name Managing Reachability Status
174
+ ///-----------------------------------
175
+
176
+ /**
177
+ Sets a callback to be executed when the network availability of the `baseURL` host changes.
178
+
179
+ @param block A block object to be executed when the network availability of the `baseURL` host changes.. This block has no return value and takes a single argument which represents the various reachability states from the device to the `baseURL`.
180
+
181
+ @warning This method requires the `SystemConfiguration` framework. Add it in the active target's "Link Binary With Library" build phase, and add `#import <SystemConfiguration/SystemConfiguration.h>` to the header prefix of the project (`Prefix.pch`).
182
+ */
183
+ #ifdef _SYSTEMCONFIGURATION_H
184
+ - (void)setReachabilityStatusChangeBlock:(void (^)(AFNetworkReachabilityStatus status))block;
185
+ #endif
186
+
187
+ ///-------------------------------
188
+ /// @name Managing HTTP Operations
189
+ ///-------------------------------
190
+
191
+ /**
192
+ Attempts to register a subclass of `AFHTTPRequestOperation`, adding it to a chain to automatically generate request operations from a URL request.
193
+
194
+ @param operationClass The subclass of `AFHTTPRequestOperation` to register
195
+
196
+ @return `YES` if the registration is successful, `NO` otherwise. The only failure condition is if `operationClass` is not a subclass of `AFHTTPRequestOperation`.
197
+
198
+ @discussion When `enqueueHTTPRequestOperationWithRequest:success:failure` is invoked, each registered class is consulted in turn to see if it can handle the specific request. The first class to return `YES` when sent a `canProcessRequest:` message is used to create an operation using `initWithURLRequest:` and do `setCompletionBlockWithSuccess:failure:`. There is no guarantee that all registered classes will be consulted. Classes are consulted in the reverse order of their registration. Attempting to register an already-registered class will move it to the top of the list.
199
+ */
200
+ - (BOOL)registerHTTPOperationClass:(Class)operationClass;
201
+
202
+ /**
203
+ Unregisters the specified subclass of `AFHTTPRequestOperation` from the chain of classes consulted when `-requestWithMethod:path:parameters` is called.
204
+
205
+ @param operationClass The subclass of `AFHTTPRequestOperation` to register
206
+ */
207
+ - (void)unregisterHTTPOperationClass:(Class)operationClass;
208
+
209
+ ///----------------------------------
210
+ /// @name Managing HTTP Header Values
211
+ ///----------------------------------
212
+
213
+ /**
214
+ Returns the value for the HTTP headers set in request objects created by the HTTP client.
215
+
216
+ @param header The HTTP header to return the default value for
217
+
218
+ @return The default value for the HTTP header, or `nil` if unspecified
219
+ */
220
+ - (NSString *)defaultValueForHeader:(NSString *)header;
221
+
222
+ /**
223
+ Sets the value for the HTTP headers set in request objects made by the HTTP client. If `nil`, removes the existing value for that header.
224
+
225
+ @param header The HTTP header to set a default value for
226
+ @param value The value set as default for the specified header, or `nil
227
+ */
228
+ - (void)setDefaultHeader:(NSString *)header
229
+ value:(NSString *)value;
230
+
231
+ /**
232
+ Sets the "Authorization" HTTP header set in request objects made by the HTTP client to a basic authentication value with Base64-encoded username and password. This overwrites any existing value for this header.
233
+
234
+ @param username The HTTP basic auth username
235
+ @param password The HTTP basic auth password
236
+ */
237
+ - (void)setAuthorizationHeaderWithUsername:(NSString *)username
238
+ password:(NSString *)password;
239
+
240
+ /**
241
+ Sets the "Authorization" HTTP header set in request objects made by the HTTP client to a token-based authentication value, such as an OAuth access token. This overwrites any existing value for this header.
242
+
243
+ @param token The authentication token
244
+ */
245
+ - (void)setAuthorizationHeaderWithToken:(NSString *)token;
246
+
247
+
248
+ /**
249
+ Clears any existing value for the "Authorization" HTTP header.
250
+ */
251
+ - (void)clearAuthorizationHeader;
252
+
253
+ ///-------------------------------
254
+ /// @name Managing URL Credentials
255
+ ///-------------------------------
256
+
257
+ /**
258
+ Set the default URL credential to be set for request operations.
259
+
260
+ @param credential The URL credential
261
+ */
262
+ - (void)setDefaultCredential:(NSURLCredential *)credential;
263
+
264
+ ///-------------------------------
265
+ /// @name Creating Request Objects
266
+ ///-------------------------------
267
+
268
+ /**
269
+ Creates an `NSMutableURLRequest` object with the specified HTTP method and path.
270
+
271
+ If the HTTP method is `GET`, `HEAD`, or `DELETE`, the parameters will be used to construct a url-encoded query string that is appended to the request's URL. Otherwise, the parameters will be encoded according to the value of the `parameterEncoding` property, and set as the request body.
272
+
273
+ @param method The HTTP method for the request, such as `GET`, `POST`, `PUT`, or `DELETE`. This parameter must not be `nil`.
274
+ @param path The path to be appended to the HTTP client's base URL and used as the request URL. If `nil`, no path will be appended to the base URL.
275
+ @param parameters The parameters to be either set as a query string for `GET` requests, or the request HTTP body.
276
+
277
+ @return An `NSMutableURLRequest` object
278
+ */
279
+ - (NSMutableURLRequest *)requestWithMethod:(NSString *)method
280
+ path:(NSString *)path
281
+ parameters:(NSDictionary *)parameters;
282
+
283
+ /**
284
+ Creates an `NSMutableURLRequest` object with the specified HTTP method and path, and constructs a `multipart/form-data` HTTP body, using the specified parameters and multipart form data block. See http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.2
285
+
286
+ @param method The HTTP method for the request. This parameter must not be `GET` or `HEAD`, or `nil`.
287
+ @param path The path to be appended to the HTTP client's base URL and used as the request URL.
288
+ @param parameters The parameters to be encoded and set in the request HTTP body.
289
+ @param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol. This can be used to upload files, encode HTTP body as JSON or XML, or specify multiple values for the same parameter, as one might for array values.
290
+
291
+ @discussion Multipart form requests are automatically streamed, reading files directly from disk along with in-memory data in a single HTTP body. The resulting `NSMutableURLRequest` object has an `HTTPBodyStream` property, so refrain from setting `HTTPBodyStream` or `HTTPBody` on this request object, as it will clear out the multipart form body stream.
292
+
293
+ @return An `NSMutableURLRequest` object
294
+ */
295
+ - (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method
296
+ path:(NSString *)path
297
+ parameters:(NSDictionary *)parameters
298
+ constructingBodyWithBlock:(void (^)(id <AFMultipartFormData> formData))block;
299
+
300
+ ///-------------------------------
301
+ /// @name Creating HTTP Operations
302
+ ///-------------------------------
303
+
304
+ /**
305
+ Creates an `AFHTTPRequestOperation`.
306
+
307
+ In order to determine what kind of operation is created, each registered subclass conforming to the `AFHTTPClient` protocol is consulted (in reverse order of when they were specified) to see if it can handle the specific request. The first class to return `YES` when sent a `canProcessRequest:` message is used to generate an operation using `HTTPRequestOperationWithRequest:success:failure:`.
308
+
309
+ @param urlRequest The request object to be loaded asynchronously during execution of the operation.
310
+ @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request.
311
+ @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred.
312
+ */
313
+ - (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)urlRequest
314
+ success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
315
+ failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
316
+
317
+ ///----------------------------------------
318
+ /// @name Managing Enqueued HTTP Operations
319
+ ///----------------------------------------
320
+
321
+ /**
322
+ Enqueues an `AFHTTPRequestOperation` to the HTTP client's operation queue.
323
+
324
+ @param operation The HTTP request operation to be enqueued.
325
+ */
326
+ - (void)enqueueHTTPRequestOperation:(AFHTTPRequestOperation *)operation;
327
+
328
+ /**
329
+ Cancels all operations in the HTTP client's operation queue whose URLs match the specified HTTP method and path.
330
+
331
+ @param method The HTTP method to match for the cancelled requests, such as `GET`, `POST`, `PUT`, or `DELETE`. If `nil`, all request operations with URLs matching the path will be cancelled.
332
+ @param path The path appended to the HTTP client base URL to match against the cancelled requests. If `nil`, no path will be appended to the base URL.
333
+
334
+ @discussion This method only cancels `AFHTTPRequestOperations` whose request URL matches the HTTP client base URL with the path appended. For complete control over the lifecycle of enqueued operations, you can access the `operationQueue` property directly, which allows you to, for instance, cancel operations filtered by a predicate, or simply use `-cancelAllRequests`. Note that the operation queue may include non-HTTP operations, so be sure to check the type before attempting to directly introspect an operation's `request` property.
335
+ */
336
+ - (void)cancelAllHTTPOperationsWithMethod:(NSString *)method path:(NSString *)path;
337
+
338
+ ///---------------------------------------
339
+ /// @name Batching HTTP Request Operations
340
+ ///---------------------------------------
341
+
342
+ /**
343
+ Creates and enqueues an `AFHTTPRequestOperation` to the HTTP client's operation queue for each specified request object into a batch. When each request operation finishes, the specified progress block is executed, until all of the request operations have finished, at which point the completion block also executes.
344
+
345
+ @param urlRequests The `NSURLRequest` objects used to create and enqueue operations.
346
+ @param progressBlock A block object to be executed upon the completion of each request operation in the batch. This block has no return value and takes two arguments: the number of operations that have already finished execution, and the total number of operations.
347
+ @param completionBlock A block object to be executed upon the completion of all of the request operations in the batch. This block has no return value and takes a single argument: the batched request operations.
348
+
349
+ @discussion Operations are created by passing the specified `NSURLRequest` objects in `requests`, using `-HTTPRequestOperationWithRequest:success:failure:`, with `nil` for both the `success` and `failure` parameters.
350
+ */
351
+ - (void)enqueueBatchOfHTTPRequestOperationsWithRequests:(NSArray *)urlRequests
352
+ progressBlock:(void (^)(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations))progressBlock
353
+ completionBlock:(void (^)(NSArray *operations))completionBlock;
354
+
355
+ /**
356
+ Enqueues the specified request operations into a batch. When each request operation finishes, the specified progress block is executed, until all of the request operations have finished, at which point the completion block also executes.
357
+
358
+ @param operations The request operations used to be batched and enqueued.
359
+ @param progressBlock A block object to be executed upon the completion of each request operation in the batch. This block has no return value and takes two arguments: the number of operations that have already finished execution, and the total number of operations.
360
+ @param completionBlock A block object to be executed upon the completion of all of the request operations in the batch. This block has no return value and takes a single argument: the batched request operations.
361
+ */
362
+ - (void)enqueueBatchOfHTTPRequestOperations:(NSArray *)operations
363
+ progressBlock:(void (^)(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations))progressBlock
364
+ completionBlock:(void (^)(NSArray *operations))completionBlock;
365
+
366
+ ///---------------------------
367
+ /// @name Making HTTP Requests
368
+ ///---------------------------
369
+
370
+ /**
371
+ Creates an `AFHTTPRequestOperation` with a `GET` request, and enqueues it to the HTTP client's operation queue.
372
+
373
+ @param path The path to be appended to the HTTP client's base URL and used as the request URL.
374
+ @param parameters The parameters to be encoded and appended as the query string for the request URL.
375
+ @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request.
376
+ @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred.
377
+
378
+ @see -HTTPRequestOperationWithRequest:success:failure:
379
+ */
380
+ - (void)getPath:(NSString *)path
381
+ parameters:(NSDictionary *)parameters
382
+ success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
383
+ failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
384
+
385
+ /**
386
+ Creates an `AFHTTPRequestOperation` with a `POST` request, and enqueues it to the HTTP client's operation queue.
387
+
388
+ @param path The path to be appended to the HTTP client's base URL and used as the request URL.
389
+ @param parameters The parameters to be encoded and set in the request HTTP body.
390
+ @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request.
391
+ @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred.
392
+
393
+ @see -HTTPRequestOperationWithRequest:success:failure:
394
+ */
395
+ - (void)postPath:(NSString *)path
396
+ parameters:(NSDictionary *)parameters
397
+ success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
398
+ failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
399
+
400
+ /**
401
+ Creates an `AFHTTPRequestOperation` with a `PUT` request, and enqueues it to the HTTP client's operation queue.
402
+
403
+ @param path The path to be appended to the HTTP client's base URL and used as the request URL.
404
+ @param parameters The parameters to be encoded and set in the request HTTP body.
405
+ @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request.
406
+ @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred.
407
+
408
+ @see -HTTPRequestOperationWithRequest:success:failure:
409
+ */
410
+ - (void)putPath:(NSString *)path
411
+ parameters:(NSDictionary *)parameters
412
+ success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
413
+ failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
414
+
415
+ /**
416
+ Creates an `AFHTTPRequestOperation` with a `DELETE` request, and enqueues it to the HTTP client's operation queue.
417
+
418
+ @param path The path to be appended to the HTTP client's base URL and used as the request URL.
419
+ @param parameters The parameters to be encoded and appended as the query string for the request URL.
420
+ @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request.
421
+ @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred.
422
+
423
+ @see -HTTPRequestOperationWithRequest:success:failure:
424
+ */
425
+ - (void)deletePath:(NSString *)path
426
+ parameters:(NSDictionary *)parameters
427
+ success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
428
+ failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
429
+
430
+ /**
431
+ Creates an `AFHTTPRequestOperation` with a `PATCH` request, and enqueues it to the HTTP client's operation queue.
432
+
433
+ @param path The path to be appended to the HTTP client's base URL and used as the request URL.
434
+ @param parameters The parameters to be encoded and set in the request HTTP body.
435
+ @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request.
436
+ @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred.
437
+
438
+ @see -HTTPRequestOperationWithRequest:success:failure:
439
+ */
440
+ - (void)patchPath:(NSString *)path
441
+ parameters:(NSDictionary *)parameters
442
+ success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
443
+ failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
444
+ @end
445
+
446
+ ///----------------
447
+ /// @name Constants
448
+ ///----------------
449
+
450
+ /**
451
+ ## Network Reachability
452
+
453
+ The following constants are provided by `AFHTTPClient` as possible network reachability statuses.
454
+
455
+ enum {
456
+ AFNetworkReachabilityStatusUnknown,
457
+ AFNetworkReachabilityStatusNotReachable,
458
+ AFNetworkReachabilityStatusReachableViaWWAN,
459
+ AFNetworkReachabilityStatusReachableViaWiFi,
460
+ }
461
+
462
+ `AFNetworkReachabilityStatusUnknown`
463
+ The `baseURL` host reachability is not known.
464
+
465
+ `AFNetworkReachabilityStatusNotReachable`
466
+ The `baseURL` host cannot be reached.
467
+
468
+ `AFNetworkReachabilityStatusReachableViaWWAN`
469
+ The `baseURL` host can be reached via a cellular connection, such as EDGE or GPRS.
470
+
471
+ `AFNetworkReachabilityStatusReachableViaWiFi`
472
+ The `baseURL` host can be reached via a Wi-Fi connection.
473
+
474
+ ### Keys for Notification UserInfo Dictionary
475
+
476
+ Strings that are used as keys in a `userInfo` dictionary in a network reachability status change notification.
477
+
478
+ `AFNetworkingReachabilityNotificationStatusItem`
479
+ A key in the userInfo dictionary in a `AFNetworkingReachabilityDidChangeNotification` notification.
480
+ The corresponding value is an `NSNumber` object representing the `AFNetworkReachabilityStatus` value for the current reachability status.
481
+
482
+ ## Parameter Encoding
483
+
484
+ The following constants are provided by `AFHTTPClient` as possible methods for serializing parameters into query string or message body values.
485
+
486
+ enum {
487
+ AFFormURLParameterEncoding,
488
+ AFJSONParameterEncoding,
489
+ AFPropertyListParameterEncoding,
490
+ }
491
+
492
+ `AFFormURLParameterEncoding`
493
+ Parameters are encoded into field/key pairs in the URL query string for `GET` `HEAD` and `DELETE` requests, and in the message body otherwise. Dictionary keys are sorted with the `caseInsensitiveCompare:` selector of their description, in order to mitigate the possibility of ambiguous query strings being generated non-deterministically. See the warning for the `parameterEncoding` property for additional information.
494
+
495
+ `AFJSONParameterEncoding`
496
+ Parameters are encoded into JSON in the message body.
497
+
498
+ `AFPropertyListParameterEncoding`
499
+ Parameters are encoded into a property list in the message body.
500
+ */
501
+
502
+ ///----------------
503
+ /// @name Functions
504
+ ///----------------
505
+
506
+ /**
507
+ Returns a query string constructed by a set of parameters, using the specified encoding.
508
+
509
+ @param parameters The parameters used to construct the query string
510
+ @param encoding The encoding to use in constructing the query string. If you are uncertain of the correct encoding, you should use UTF-8 (`NSUTF8StringEncoding`), which is the encoding designated by RFC 3986 as the correct encoding for use in URLs.
511
+
512
+ @discussion Query strings are constructed by collecting each key-value pair, percent escaping a string representation of the key-value pair, and then joining the pairs with "&".
513
+
514
+ If a query string pair has a an `NSArray` for its value, each member of the array will be represented in the format `field[]=value1&field[]value2`. Otherwise, the pair will be formatted as "field=value". String representations of both keys and values are derived using the `-description` method. The constructed query string does not include the ? character used to delimit the query component.
515
+
516
+ @return A percent-escaped query string
517
+ */
518
+ extern NSString * AFQueryStringFromParametersWithEncoding(NSDictionary *parameters, NSStringEncoding encoding);
519
+
520
+ ///--------------------
521
+ /// @name Notifications
522
+ ///--------------------
523
+
524
+ /**
525
+ Posted when network reachability changes.
526
+ This notification assigns no notification object. The `userInfo` dictionary contains an `NSNumber` object under the `AFNetworkingReachabilityNotificationStatusItem` key, representing the `AFNetworkReachabilityStatus` value for the current network reachability.
527
+
528
+ @warning In order for network reachability to be monitored, include the `SystemConfiguration` framework in the active target's "Link Binary With Library" build phase, and add `#import <SystemConfiguration/SystemConfiguration.h>` to the header prefix of the project (`Prefix.pch`).
529
+ */
530
+ #ifdef _SYSTEMCONFIGURATION_H
531
+ extern NSString * const AFNetworkingReachabilityDidChangeNotification;
532
+ extern NSString * const AFNetworkingReachabilityNotificationStatusItem;
533
+ #endif
534
+
535
+ #pragma mark -
536
+
537
+ extern NSUInteger const kAFUploadStream3GSuggestedPacketSize;
538
+ extern NSTimeInterval const kAFUploadStream3GSuggestedDelay;
539
+
540
+ /**
541
+ The `AFMultipartFormData` protocol defines the methods supported by the parameter in the block argument of `AFHTTPClient -multipartFormRequestWithMethod:path:parameters:constructingBodyWithBlock:`.
542
+ */
543
+ @protocol AFMultipartFormData
544
+
545
+ /**
546
+ Appends the HTTP header `Content-Disposition: file; filename=#{generated filename}; name=#{name}"` and `Content-Type: #{generated mimeType}`, followed by the encoded file data and the multipart form boundary.
547
+
548
+ @param fileURL The URL corresponding to the file whose content will be appended to the form. This parameter must not be `nil`.
549
+ @param name The name to be associated with the specified data. This parameter must not be `nil`.
550
+ @param error If an error occurs, upon return contains an `NSError` object that describes the problem.
551
+
552
+ @return `YES` if the file data was successfully appended, otherwise `NO`.
553
+
554
+ @discussion The filename and MIME type for this data in the form will be automatically generated, using the last path component of the `fileURL` and system associated MIME type for the `fileURL` extension, respectively.
555
+ */
556
+ - (BOOL)appendPartWithFileURL:(NSURL *)fileURL
557
+ name:(NSString *)name
558
+ error:(NSError * __autoreleasing *)error;
559
+
560
+ /**
561
+ Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary.
562
+
563
+ @param fileURL The URL corresponding to the file whose content will be appended to the form. This parameter must not be `nil`.
564
+ @param name The name to be associated with the specified data. This parameter must not be `nil`.
565
+ @param fileName The file name to be used in the `Content-Disposition` header. This parameter must not be `nil`.
566
+ @param mimeType The declared MIME type of the file data. This parameter must not be `nil`.
567
+ @param error If an error occurs, upon return contains an `NSError` object that describes the problem.
568
+
569
+ @return `YES` if the file data was successfully appended otherwise `NO`.
570
+ */
571
+ - (BOOL)appendPartWithFileURL:(NSURL *)fileURL
572
+ name:(NSString *)name
573
+ fileName:(NSString *)fileName
574
+ mimeType:(NSString *)mimeType
575
+ error:(NSError * __autoreleasing *)error;
576
+
577
+ /**
578
+ Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the data from the input stream and the multipart form boundary.
579
+
580
+ @param inputStream The input stream to be appended to the form data
581
+ @param name The name to be associated with the specified input stream. This parameter must not be `nil`.
582
+ @param fileName The filename to be associated with the specified input stream. This parameter must not be `nil`.
583
+ @param length The length of the specified input stream in bytes.
584
+ @param mimeType The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be `nil`.
585
+ */
586
+ - (void)appendPartWithInputStream:(NSInputStream *)inputStream
587
+ name:(NSString *)name
588
+ fileName:(NSString *)fileName
589
+ length:(unsigned long long)length
590
+ mimeType:(NSString *)mimeType;
591
+
592
+ /**
593
+ Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary.
594
+
595
+ @param data The data to be encoded and appended to the form data.
596
+ @param name The name to be associated with the specified data. This parameter must not be `nil`.
597
+ @param fileName The filename to be associated with the specified data. This parameter must not be `nil`.
598
+ @param mimeType The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be `nil`.
599
+ */
600
+ - (void)appendPartWithFileData:(NSData *)data
601
+ name:(NSString *)name
602
+ fileName:(NSString *)fileName
603
+ mimeType:(NSString *)mimeType;
604
+
605
+ /**
606
+ Appends the HTTP headers `Content-Disposition: form-data; name=#{name}"`, followed by the encoded data and the multipart form boundary.
607
+
608
+ @param data The data to be encoded and appended to the form data.
609
+ @param name The name to be associated with the specified data. This parameter must not be `nil`.
610
+ */
611
+
612
+ - (void)appendPartWithFormData:(NSData *)data
613
+ name:(NSString *)name;
614
+
615
+
616
+ /**
617
+ Appends HTTP headers, followed by the encoded data and the multipart form boundary.
618
+
619
+ @param headers The HTTP headers to be appended to the form data.
620
+ @param body The data to be encoded and appended to the form data.
621
+ */
622
+ - (void)appendPartWithHeaders:(NSDictionary *)headers
623
+ body:(NSData *)body;
624
+
625
+ /**
626
+ Throttles request bandwidth by limiting the packet size and adding a delay for each chunk read from the upload stream.
627
+
628
+ @param numberOfBytes Maximum packet size, in number of bytes. The default packet size for an input stream is 32kb.
629
+ @param delay Duration of delay each time a packet is read. By default, no delay is set.
630
+
631
+ @discussion When uploading over a 3G or EDGE connection, requests may fail with "request body stream exhausted". Setting a maximum packet size and delay according to the recommended values (`kAFUploadStream3GSuggestedPacketSize` and `kAFUploadStream3GSuggestedDelay`) lowers the risk of the input stream exceeding its allocated bandwidth. Unfortunately, as of iOS 6, there is no definite way to distinguish between a 3G, EDGE, or LTE connection. As such, it is not recommended that you throttle bandwidth based solely on network reachability. Instead, you should consider checking for the "request body stream exhausted" in a failure block, and then retrying the request with throttled bandwidth.
632
+ */
633
+ - (void)throttleBandwidthWithPacketSize:(NSUInteger)numberOfBytes
634
+ delay:(NSTimeInterval)delay;
635
+
636
+ @end