├── DCTConnectionController.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── DCTConnectionController ├── DCTConnectionController+BlockHandlers.h ├── DCTConnectionController+BlockHandlers.m ├── DCTConnectionController+Equality.h ├── DCTConnectionController+Equality.m ├── DCTConnectionController.h ├── DCTConnectionController.m ├── DCTConnectionControllerDisplay.h ├── DCTConnectionControllerDisplay.m ├── DCTConnectionQueue.h ├── DCTConnectionQueue.m ├── DCTRESTConnectionController.h ├── DCTRESTConnectionController.m ├── NSString+DCTURLEncoding.h ├── NSString+DCTURLEncoding.m └── _DCTConnectionQueue.h ├── DCTConnectionControllerTests ├── DCTConnectionControllerTests-Info.plist ├── DCTConnectionControllerTests.h ├── DCTConnectionControllerTests.m └── en.lproj │ └── InfoPlist.strings ├── Mac Demo ├── AppDelegate.h ├── AppDelegate.m ├── Mac Demo-Info.plist ├── Mac Demo-Prefix.pch ├── en.lproj │ ├── Credits.rtf │ ├── InfoPlist.strings │ └── MainMenu.xib └── main.m ├── Readme.textile └── iPhone Demo ├── AppDelegate.h ├── AppDelegate.m ├── DCTConnectionControllerDemo-Info.plist ├── DCTConnectionControllerDemo-Prefix.pch ├── ViewController.h ├── ViewController.m ├── ViewController.xib ├── en.lproj └── InfoPlist.strings └── main.m /DCTConnectionController.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 2437B5DD15B9771F00750117 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 24F6EC3F158A2BD100CEDD41 /* Foundation.framework */; }; 11 | 2437B5E815B9772900750117 /* DCTConnectionController+BlockHandlers.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 24F6EC69158A2C3000CEDD41 /* DCTConnectionController+BlockHandlers.h */; }; 12 | 2437B5E915B9773300750117 /* DCTConnectionQueue.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 24F6EC73158A2C3000CEDD41 /* DCTConnectionQueue.h */; }; 13 | 2437B5EA15B9773A00750117 /* DCTRESTConnectionController.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 24F6EC75158A2C3000CEDD41 /* DCTRESTConnectionController.h */; }; 14 | 2437B5EB15B9773D00750117 /* NSString+DCTURLEncoding.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 24F6EC77158A2C3000CEDD41 /* NSString+DCTURLEncoding.h */; }; 15 | 2437B5EC15B9774C00750117 /* DCTConnectionController+BlockHandlers.m in Sources */ = {isa = PBXBuildFile; fileRef = 24F6EC6A158A2C3000CEDD41 /* DCTConnectionController+BlockHandlers.m */; }; 16 | 2437B5ED15B9775000750117 /* DCTConnectionController+Equality.m in Sources */ = {isa = PBXBuildFile; fileRef = 24F6EC6C158A2C3000CEDD41 /* DCTConnectionController+Equality.m */; }; 17 | 2437B5EE15B9775400750117 /* DCTConnectionControllerDisplay.m in Sources */ = {isa = PBXBuildFile; fileRef = 24F6EC70158A2C3000CEDD41 /* DCTConnectionControllerDisplay.m */; }; 18 | 2437B5EF15B9775800750117 /* DCTConnectionQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = 24F6EC74158A2C3000CEDD41 /* DCTConnectionQueue.m */; }; 19 | 2437B5F015B9775D00750117 /* DCTRESTConnectionController.m in Sources */ = {isa = PBXBuildFile; fileRef = 24F6EC76158A2C3000CEDD41 /* DCTRESTConnectionController.m */; }; 20 | 2437B5F115B9776100750117 /* NSString+DCTURLEncoding.m in Sources */ = {isa = PBXBuildFile; fileRef = 24F6EC78158A2C3000CEDD41 /* NSString+DCTURLEncoding.m */; }; 21 | 2437B66C15B97B3500750117 /* DCTConnectionController.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 24F6EC67158A2C3000CEDD41 /* DCTConnectionController.h */; }; 22 | 2437B66D15B97B4400750117 /* DCTConnectionController.m in Sources */ = {isa = PBXBuildFile; fileRef = 24F6EC68158A2C3000CEDD41 /* DCTConnectionController.m */; }; 23 | 247CBC941598FD960006A011 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 247CBC921598FD960006A011 /* ViewController.m */; }; 24 | 247CBC951598FD960006A011 /* ViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 247CBC931598FD960006A011 /* ViewController.xib */; }; 25 | 248DBAC915D51FE700710CB0 /* libDCTConnectionController.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2437B5DC15B9771F00750117 /* libDCTConnectionController.a */; }; 26 | 249D6E3C159890F300FE9A23 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 24F6EC4F158A2BD200CEDD41 /* UIKit.framework */; }; 27 | 249D6E3D159890F300FE9A23 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 24F6EC3F158A2BD100CEDD41 /* Foundation.framework */; }; 28 | 249D6E3F159890F300FE9A23 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 249D6E3E159890F300FE9A23 /* CoreGraphics.framework */; }; 29 | 249D6E45159890F300FE9A23 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 249D6E43159890F300FE9A23 /* InfoPlist.strings */; }; 30 | 249D6E47159890F300FE9A23 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 249D6E46159890F300FE9A23 /* main.m */; }; 31 | 249D6E4B159890F300FE9A23 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 249D6E4A159890F300FE9A23 /* AppDelegate.m */; }; 32 | 24BE261215A7410100161A59 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 24BE261115A7410100161A59 /* Cocoa.framework */; }; 33 | 24BE261C15A7410100161A59 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 24BE261A15A7410100161A59 /* InfoPlist.strings */; }; 34 | 24BE261E15A7410100161A59 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 24BE261D15A7410100161A59 /* main.m */; }; 35 | 24BE262215A7410100161A59 /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = 24BE262015A7410100161A59 /* Credits.rtf */; }; 36 | 24BE262515A7410100161A59 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 24BE262415A7410100161A59 /* AppDelegate.m */; }; 37 | 24BE262815A7410100161A59 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 24BE262615A7410100161A59 /* MainMenu.xib */; }; 38 | 24F6EC4E158A2BD200CEDD41 /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 24F6EC4D158A2BD200CEDD41 /* SenTestingKit.framework */; }; 39 | 24F6EC50158A2BD200CEDD41 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 24F6EC4F158A2BD200CEDD41 /* UIKit.framework */; }; 40 | 24F6EC51158A2BD200CEDD41 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 24F6EC3F158A2BD100CEDD41 /* Foundation.framework */; }; 41 | 24F6EC5A158A2BD200CEDD41 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 24F6EC58158A2BD200CEDD41 /* InfoPlist.strings */; }; 42 | 24F6EC5D158A2BD200CEDD41 /* DCTConnectionControllerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 24F6EC5C158A2BD200CEDD41 /* DCTConnectionControllerTests.m */; }; 43 | /* End PBXBuildFile section */ 44 | 45 | /* Begin PBXCopyFilesBuildPhase section */ 46 | 2437B5DA15B9771F00750117 /* CopyFiles */ = { 47 | isa = PBXCopyFilesBuildPhase; 48 | buildActionMask = 2147483647; 49 | dstPath = "include/${PRODUCT_NAME}"; 50 | dstSubfolderSpec = 16; 51 | files = ( 52 | 2437B66C15B97B3500750117 /* DCTConnectionController.h in CopyFiles */, 53 | 2437B5E815B9772900750117 /* DCTConnectionController+BlockHandlers.h in CopyFiles */, 54 | 2437B5E915B9773300750117 /* DCTConnectionQueue.h in CopyFiles */, 55 | 2437B5EA15B9773A00750117 /* DCTRESTConnectionController.h in CopyFiles */, 56 | 2437B5EB15B9773D00750117 /* NSString+DCTURLEncoding.h in CopyFiles */, 57 | ); 58 | runOnlyForDeploymentPostprocessing = 0; 59 | }; 60 | /* End PBXCopyFilesBuildPhase section */ 61 | 62 | /* Begin PBXFileReference section */ 63 | 2437B5DC15B9771F00750117 /* libDCTConnectionController.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libDCTConnectionController.a; sourceTree = BUILT_PRODUCTS_DIR; }; 64 | 24477ECD15B48A43005A314B /* _DCTConnectionQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _DCTConnectionQueue.h; sourceTree = ""; }; 65 | 247CBC911598FD960006A011 /* ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 66 | 247CBC921598FD960006A011 /* ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 67 | 247CBC931598FD960006A011 /* ViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ViewController.xib; sourceTree = ""; }; 68 | 249D6E3A159890F300FE9A23 /* iPhone Demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "iPhone Demo.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 69 | 249D6E3E159890F300FE9A23 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 70 | 249D6E42159890F300FE9A23 /* DCTConnectionControllerDemo-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "DCTConnectionControllerDemo-Info.plist"; sourceTree = ""; }; 71 | 249D6E44159890F300FE9A23 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 72 | 249D6E46159890F300FE9A23 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 73 | 249D6E48159890F300FE9A23 /* DCTConnectionControllerDemo-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "DCTConnectionControllerDemo-Prefix.pch"; sourceTree = ""; }; 74 | 249D6E49159890F300FE9A23 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 75 | 249D6E4A159890F300FE9A23 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 76 | 24BE260F15A7410100161A59 /* DCTConnectionController.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DCTConnectionController.app; sourceTree = BUILT_PRODUCTS_DIR; }; 77 | 24BE261115A7410100161A59 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = Library/Frameworks/Cocoa.framework; sourceTree = DEVELOPER_DIR; }; 78 | 24BE261415A7410100161A59 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; 79 | 24BE261515A7410100161A59 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; }; 80 | 24BE261615A7410100161A59 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 81 | 24BE261915A7410100161A59 /* Mac Demo-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Mac Demo-Info.plist"; sourceTree = ""; }; 82 | 24BE261B15A7410100161A59 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 83 | 24BE261D15A7410100161A59 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 84 | 24BE261F15A7410100161A59 /* Mac Demo-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Mac Demo-Prefix.pch"; sourceTree = ""; }; 85 | 24BE262115A7410100161A59 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; name = en; path = en.lproj/Credits.rtf; sourceTree = ""; }; 86 | 24BE262315A7410100161A59 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 87 | 24BE262415A7410100161A59 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 88 | 24BE262715A7410100161A59 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainMenu.xib; sourceTree = ""; }; 89 | 24F6EC3F158A2BD100CEDD41 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 90 | 24F6EC4C158A2BD200CEDD41 /* DCTConnectionControllerTests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DCTConnectionControllerTests.octest; sourceTree = BUILT_PRODUCTS_DIR; }; 91 | 24F6EC4D158A2BD200CEDD41 /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_DIR; }; 92 | 24F6EC4F158A2BD200CEDD41 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; 93 | 24F6EC57158A2BD200CEDD41 /* DCTConnectionControllerTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "DCTConnectionControllerTests-Info.plist"; sourceTree = ""; }; 94 | 24F6EC59158A2BD200CEDD41 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 95 | 24F6EC5B158A2BD200CEDD41 /* DCTConnectionControllerTests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DCTConnectionControllerTests.h; sourceTree = ""; }; 96 | 24F6EC5C158A2BD200CEDD41 /* DCTConnectionControllerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DCTConnectionControllerTests.m; sourceTree = ""; }; 97 | 24F6EC67158A2C3000CEDD41 /* DCTConnectionController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DCTConnectionController.h; sourceTree = ""; }; 98 | 24F6EC68158A2C3000CEDD41 /* DCTConnectionController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DCTConnectionController.m; sourceTree = ""; }; 99 | 24F6EC69158A2C3000CEDD41 /* DCTConnectionController+BlockHandlers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DCTConnectionController+BlockHandlers.h"; sourceTree = ""; }; 100 | 24F6EC6A158A2C3000CEDD41 /* DCTConnectionController+BlockHandlers.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "DCTConnectionController+BlockHandlers.m"; sourceTree = ""; }; 101 | 24F6EC6B158A2C3000CEDD41 /* DCTConnectionController+Equality.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DCTConnectionController+Equality.h"; sourceTree = ""; }; 102 | 24F6EC6C158A2C3000CEDD41 /* DCTConnectionController+Equality.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "DCTConnectionController+Equality.m"; sourceTree = ""; }; 103 | 24F6EC6F158A2C3000CEDD41 /* DCTConnectionControllerDisplay.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DCTConnectionControllerDisplay.h; sourceTree = ""; }; 104 | 24F6EC70158A2C3000CEDD41 /* DCTConnectionControllerDisplay.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DCTConnectionControllerDisplay.m; sourceTree = ""; }; 105 | 24F6EC73158A2C3000CEDD41 /* DCTConnectionQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DCTConnectionQueue.h; sourceTree = ""; }; 106 | 24F6EC74158A2C3000CEDD41 /* DCTConnectionQueue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DCTConnectionQueue.m; sourceTree = ""; }; 107 | 24F6EC75158A2C3000CEDD41 /* DCTRESTConnectionController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DCTRESTConnectionController.h; sourceTree = ""; }; 108 | 24F6EC76158A2C3000CEDD41 /* DCTRESTConnectionController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DCTRESTConnectionController.m; sourceTree = ""; }; 109 | 24F6EC77158A2C3000CEDD41 /* NSString+DCTURLEncoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+DCTURLEncoding.h"; sourceTree = ""; }; 110 | 24F6EC78158A2C3000CEDD41 /* NSString+DCTURLEncoding.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+DCTURLEncoding.m"; sourceTree = ""; }; 111 | /* End PBXFileReference section */ 112 | 113 | /* Begin PBXFrameworksBuildPhase section */ 114 | 2437B5D915B9771F00750117 /* Frameworks */ = { 115 | isa = PBXFrameworksBuildPhase; 116 | buildActionMask = 2147483647; 117 | files = ( 118 | 2437B5DD15B9771F00750117 /* Foundation.framework in Frameworks */, 119 | ); 120 | runOnlyForDeploymentPostprocessing = 0; 121 | }; 122 | 249D6E37159890F300FE9A23 /* Frameworks */ = { 123 | isa = PBXFrameworksBuildPhase; 124 | buildActionMask = 2147483647; 125 | files = ( 126 | 248DBAC915D51FE700710CB0 /* libDCTConnectionController.a in Frameworks */, 127 | 249D6E3C159890F300FE9A23 /* UIKit.framework in Frameworks */, 128 | 249D6E3D159890F300FE9A23 /* Foundation.framework in Frameworks */, 129 | 249D6E3F159890F300FE9A23 /* CoreGraphics.framework in Frameworks */, 130 | ); 131 | runOnlyForDeploymentPostprocessing = 0; 132 | }; 133 | 24BE260C15A7410100161A59 /* Frameworks */ = { 134 | isa = PBXFrameworksBuildPhase; 135 | buildActionMask = 2147483647; 136 | files = ( 137 | 24BE261215A7410100161A59 /* Cocoa.framework in Frameworks */, 138 | ); 139 | runOnlyForDeploymentPostprocessing = 0; 140 | }; 141 | 24F6EC48158A2BD200CEDD41 /* Frameworks */ = { 142 | isa = PBXFrameworksBuildPhase; 143 | buildActionMask = 2147483647; 144 | files = ( 145 | 24F6EC4E158A2BD200CEDD41 /* SenTestingKit.framework in Frameworks */, 146 | 24F6EC50158A2BD200CEDD41 /* UIKit.framework in Frameworks */, 147 | 24F6EC51158A2BD200CEDD41 /* Foundation.framework in Frameworks */, 148 | ); 149 | runOnlyForDeploymentPostprocessing = 0; 150 | }; 151 | /* End PBXFrameworksBuildPhase section */ 152 | 153 | /* Begin PBXGroup section */ 154 | 249D6E40159890F300FE9A23 /* iPhone Demo */ = { 155 | isa = PBXGroup; 156 | children = ( 157 | 249D6E49159890F300FE9A23 /* AppDelegate.h */, 158 | 249D6E4A159890F300FE9A23 /* AppDelegate.m */, 159 | 247CBC911598FD960006A011 /* ViewController.h */, 160 | 247CBC921598FD960006A011 /* ViewController.m */, 161 | 247CBC931598FD960006A011 /* ViewController.xib */, 162 | 249D6E41159890F300FE9A23 /* Supporting Files */, 163 | ); 164 | path = "iPhone Demo"; 165 | sourceTree = ""; 166 | }; 167 | 249D6E41159890F300FE9A23 /* Supporting Files */ = { 168 | isa = PBXGroup; 169 | children = ( 170 | 249D6E42159890F300FE9A23 /* DCTConnectionControllerDemo-Info.plist */, 171 | 249D6E43159890F300FE9A23 /* InfoPlist.strings */, 172 | 249D6E46159890F300FE9A23 /* main.m */, 173 | 249D6E48159890F300FE9A23 /* DCTConnectionControllerDemo-Prefix.pch */, 174 | ); 175 | name = "Supporting Files"; 176 | sourceTree = ""; 177 | }; 178 | 24BE261315A7410100161A59 /* Other Frameworks */ = { 179 | isa = PBXGroup; 180 | children = ( 181 | 24BE261415A7410100161A59 /* AppKit.framework */, 182 | 24BE261515A7410100161A59 /* CoreData.framework */, 183 | 24BE261615A7410100161A59 /* Foundation.framework */, 184 | ); 185 | name = "Other Frameworks"; 186 | sourceTree = ""; 187 | }; 188 | 24BE261715A7410100161A59 /* Mac Demo */ = { 189 | isa = PBXGroup; 190 | children = ( 191 | 24BE262315A7410100161A59 /* AppDelegate.h */, 192 | 24BE262415A7410100161A59 /* AppDelegate.m */, 193 | 24BE262615A7410100161A59 /* MainMenu.xib */, 194 | 24BE261815A7410100161A59 /* Supporting Files */, 195 | ); 196 | path = "Mac Demo"; 197 | sourceTree = ""; 198 | }; 199 | 24BE261815A7410100161A59 /* Supporting Files */ = { 200 | isa = PBXGroup; 201 | children = ( 202 | 24BE261915A7410100161A59 /* Mac Demo-Info.plist */, 203 | 24BE261A15A7410100161A59 /* InfoPlist.strings */, 204 | 24BE261D15A7410100161A59 /* main.m */, 205 | 24BE261F15A7410100161A59 /* Mac Demo-Prefix.pch */, 206 | 24BE262015A7410100161A59 /* Credits.rtf */, 207 | ); 208 | name = "Supporting Files"; 209 | sourceTree = ""; 210 | }; 211 | 24F6EC31158A2BD100CEDD41 = { 212 | isa = PBXGroup; 213 | children = ( 214 | 24F6EC41158A2BD100CEDD41 /* DCTConnectionController */, 215 | 24F6EC55158A2BD200CEDD41 /* DCTConnectionControllerTests */, 216 | 249D6E40159890F300FE9A23 /* iPhone Demo */, 217 | 24BE261715A7410100161A59 /* Mac Demo */, 218 | 24F6EC3E158A2BD100CEDD41 /* Frameworks */, 219 | 24F6EC3D158A2BD100CEDD41 /* Products */, 220 | ); 221 | sourceTree = ""; 222 | }; 223 | 24F6EC3D158A2BD100CEDD41 /* Products */ = { 224 | isa = PBXGroup; 225 | children = ( 226 | 24F6EC4C158A2BD200CEDD41 /* DCTConnectionControllerTests.octest */, 227 | 249D6E3A159890F300FE9A23 /* iPhone Demo.app */, 228 | 24BE260F15A7410100161A59 /* DCTConnectionController.app */, 229 | 2437B5DC15B9771F00750117 /* libDCTConnectionController.a */, 230 | ); 231 | name = Products; 232 | sourceTree = ""; 233 | }; 234 | 24F6EC3E158A2BD100CEDD41 /* Frameworks */ = { 235 | isa = PBXGroup; 236 | children = ( 237 | 24F6EC3F158A2BD100CEDD41 /* Foundation.framework */, 238 | 24F6EC4D158A2BD200CEDD41 /* SenTestingKit.framework */, 239 | 24F6EC4F158A2BD200CEDD41 /* UIKit.framework */, 240 | 249D6E3E159890F300FE9A23 /* CoreGraphics.framework */, 241 | 24BE261115A7410100161A59 /* Cocoa.framework */, 242 | 24BE261315A7410100161A59 /* Other Frameworks */, 243 | ); 244 | name = Frameworks; 245 | sourceTree = ""; 246 | }; 247 | 24F6EC41158A2BD100CEDD41 /* DCTConnectionController */ = { 248 | isa = PBXGroup; 249 | children = ( 250 | 24F6EC67158A2C3000CEDD41 /* DCTConnectionController.h */, 251 | 24F6EC68158A2C3000CEDD41 /* DCTConnectionController.m */, 252 | 24F6EC69158A2C3000CEDD41 /* DCTConnectionController+BlockHandlers.h */, 253 | 24F6EC6A158A2C3000CEDD41 /* DCTConnectionController+BlockHandlers.m */, 254 | 24F6EC6B158A2C3000CEDD41 /* DCTConnectionController+Equality.h */, 255 | 24F6EC6C158A2C3000CEDD41 /* DCTConnectionController+Equality.m */, 256 | 24F6EC6F158A2C3000CEDD41 /* DCTConnectionControllerDisplay.h */, 257 | 24F6EC70158A2C3000CEDD41 /* DCTConnectionControllerDisplay.m */, 258 | 24F6EC73158A2C3000CEDD41 /* DCTConnectionQueue.h */, 259 | 24F6EC74158A2C3000CEDD41 /* DCTConnectionQueue.m */, 260 | 24477ECD15B48A43005A314B /* _DCTConnectionQueue.h */, 261 | 24F6EC75158A2C3000CEDD41 /* DCTRESTConnectionController.h */, 262 | 24F6EC76158A2C3000CEDD41 /* DCTRESTConnectionController.m */, 263 | 24F6EC77158A2C3000CEDD41 /* NSString+DCTURLEncoding.h */, 264 | 24F6EC78158A2C3000CEDD41 /* NSString+DCTURLEncoding.m */, 265 | ); 266 | path = DCTConnectionController; 267 | sourceTree = ""; 268 | }; 269 | 24F6EC55158A2BD200CEDD41 /* DCTConnectionControllerTests */ = { 270 | isa = PBXGroup; 271 | children = ( 272 | 24F6EC5B158A2BD200CEDD41 /* DCTConnectionControllerTests.h */, 273 | 24F6EC5C158A2BD200CEDD41 /* DCTConnectionControllerTests.m */, 274 | 24F6EC56158A2BD200CEDD41 /* Supporting Files */, 275 | ); 276 | path = DCTConnectionControllerTests; 277 | sourceTree = ""; 278 | }; 279 | 24F6EC56158A2BD200CEDD41 /* Supporting Files */ = { 280 | isa = PBXGroup; 281 | children = ( 282 | 24F6EC57158A2BD200CEDD41 /* DCTConnectionControllerTests-Info.plist */, 283 | 24F6EC58158A2BD200CEDD41 /* InfoPlist.strings */, 284 | ); 285 | name = "Supporting Files"; 286 | sourceTree = ""; 287 | }; 288 | /* End PBXGroup section */ 289 | 290 | /* Begin PBXNativeTarget section */ 291 | 2437B5DB15B9771F00750117 /* DCTConnectionController */ = { 292 | isa = PBXNativeTarget; 293 | buildConfigurationList = 2437B5E515B9771F00750117 /* Build configuration list for PBXNativeTarget "DCTConnectionController" */; 294 | buildPhases = ( 295 | 2437B5D815B9771F00750117 /* Sources */, 296 | 2437B5D915B9771F00750117 /* Frameworks */, 297 | 2437B5DA15B9771F00750117 /* CopyFiles */, 298 | ); 299 | buildRules = ( 300 | ); 301 | dependencies = ( 302 | ); 303 | name = DCTConnectionController; 304 | productName = DCTConnectionController; 305 | productReference = 2437B5DC15B9771F00750117 /* libDCTConnectionController.a */; 306 | productType = "com.apple.product-type.library.static"; 307 | }; 308 | 249D6E39159890F300FE9A23 /* iPhone Demo */ = { 309 | isa = PBXNativeTarget; 310 | buildConfigurationList = 249D6E4E159890F300FE9A23 /* Build configuration list for PBXNativeTarget "iPhone Demo" */; 311 | buildPhases = ( 312 | 249D6E36159890F300FE9A23 /* Sources */, 313 | 249D6E37159890F300FE9A23 /* Frameworks */, 314 | 249D6E38159890F300FE9A23 /* Resources */, 315 | ); 316 | buildRules = ( 317 | ); 318 | dependencies = ( 319 | ); 320 | name = "iPhone Demo"; 321 | productName = DCTConnectionControllerDemo; 322 | productReference = 249D6E3A159890F300FE9A23 /* iPhone Demo.app */; 323 | productType = "com.apple.product-type.application"; 324 | }; 325 | 24BE260E15A7410100161A59 /* Mac Demo */ = { 326 | isa = PBXNativeTarget; 327 | buildConfigurationList = 24BE262915A7410100161A59 /* Build configuration list for PBXNativeTarget "Mac Demo" */; 328 | buildPhases = ( 329 | 24BE260B15A7410100161A59 /* Sources */, 330 | 24BE260C15A7410100161A59 /* Frameworks */, 331 | 24BE260D15A7410100161A59 /* Resources */, 332 | ); 333 | buildRules = ( 334 | ); 335 | dependencies = ( 336 | ); 337 | name = "Mac Demo"; 338 | productName = "Mac Demo"; 339 | productReference = 24BE260F15A7410100161A59 /* DCTConnectionController.app */; 340 | productType = "com.apple.product-type.application"; 341 | }; 342 | 24F6EC4B158A2BD200CEDD41 /* DCTConnectionControllerTests */ = { 343 | isa = PBXNativeTarget; 344 | buildConfigurationList = 24F6EC63158A2BD200CEDD41 /* Build configuration list for PBXNativeTarget "DCTConnectionControllerTests" */; 345 | buildPhases = ( 346 | 24F6EC47158A2BD200CEDD41 /* Sources */, 347 | 24F6EC48158A2BD200CEDD41 /* Frameworks */, 348 | 24F6EC49158A2BD200CEDD41 /* Resources */, 349 | 24F6EC4A158A2BD200CEDD41 /* ShellScript */, 350 | ); 351 | buildRules = ( 352 | ); 353 | dependencies = ( 354 | ); 355 | name = DCTConnectionControllerTests; 356 | productName = DCTConnectionControllerTests; 357 | productReference = 24F6EC4C158A2BD200CEDD41 /* DCTConnectionControllerTests.octest */; 358 | productType = "com.apple.product-type.bundle"; 359 | }; 360 | /* End PBXNativeTarget section */ 361 | 362 | /* Begin PBXProject section */ 363 | 24F6EC33158A2BD100CEDD41 /* Project object */ = { 364 | isa = PBXProject; 365 | attributes = { 366 | LastUpgradeCheck = 0500; 367 | ORGANIZATIONNAME = "Daniel Tull"; 368 | }; 369 | buildConfigurationList = 24F6EC36158A2BD100CEDD41 /* Build configuration list for PBXProject "DCTConnectionController" */; 370 | compatibilityVersion = "Xcode 3.2"; 371 | developmentRegion = English; 372 | hasScannedForEncodings = 0; 373 | knownRegions = ( 374 | en, 375 | ); 376 | mainGroup = 24F6EC31158A2BD100CEDD41; 377 | productRefGroup = 24F6EC3D158A2BD100CEDD41 /* Products */; 378 | projectDirPath = ""; 379 | projectRoot = ""; 380 | targets = ( 381 | 2437B5DB15B9771F00750117 /* DCTConnectionController */, 382 | 24F6EC4B158A2BD200CEDD41 /* DCTConnectionControllerTests */, 383 | 249D6E39159890F300FE9A23 /* iPhone Demo */, 384 | 24BE260E15A7410100161A59 /* Mac Demo */, 385 | ); 386 | }; 387 | /* End PBXProject section */ 388 | 389 | /* Begin PBXResourcesBuildPhase section */ 390 | 249D6E38159890F300FE9A23 /* Resources */ = { 391 | isa = PBXResourcesBuildPhase; 392 | buildActionMask = 2147483647; 393 | files = ( 394 | 249D6E45159890F300FE9A23 /* InfoPlist.strings in Resources */, 395 | 247CBC951598FD960006A011 /* ViewController.xib in Resources */, 396 | ); 397 | runOnlyForDeploymentPostprocessing = 0; 398 | }; 399 | 24BE260D15A7410100161A59 /* Resources */ = { 400 | isa = PBXResourcesBuildPhase; 401 | buildActionMask = 2147483647; 402 | files = ( 403 | 24BE261C15A7410100161A59 /* InfoPlist.strings in Resources */, 404 | 24BE262215A7410100161A59 /* Credits.rtf in Resources */, 405 | 24BE262815A7410100161A59 /* MainMenu.xib in Resources */, 406 | ); 407 | runOnlyForDeploymentPostprocessing = 0; 408 | }; 409 | 24F6EC49158A2BD200CEDD41 /* Resources */ = { 410 | isa = PBXResourcesBuildPhase; 411 | buildActionMask = 2147483647; 412 | files = ( 413 | 24F6EC5A158A2BD200CEDD41 /* InfoPlist.strings in Resources */, 414 | ); 415 | runOnlyForDeploymentPostprocessing = 0; 416 | }; 417 | /* End PBXResourcesBuildPhase section */ 418 | 419 | /* Begin PBXShellScriptBuildPhase section */ 420 | 24F6EC4A158A2BD200CEDD41 /* ShellScript */ = { 421 | isa = PBXShellScriptBuildPhase; 422 | buildActionMask = 2147483647; 423 | files = ( 424 | ); 425 | inputPaths = ( 426 | ); 427 | outputPaths = ( 428 | ); 429 | runOnlyForDeploymentPostprocessing = 0; 430 | shellPath = /bin/sh; 431 | shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n"; 432 | }; 433 | /* End PBXShellScriptBuildPhase section */ 434 | 435 | /* Begin PBXSourcesBuildPhase section */ 436 | 2437B5D815B9771F00750117 /* Sources */ = { 437 | isa = PBXSourcesBuildPhase; 438 | buildActionMask = 2147483647; 439 | files = ( 440 | 2437B66D15B97B4400750117 /* DCTConnectionController.m in Sources */, 441 | 2437B5EC15B9774C00750117 /* DCTConnectionController+BlockHandlers.m in Sources */, 442 | 2437B5ED15B9775000750117 /* DCTConnectionController+Equality.m in Sources */, 443 | 2437B5EE15B9775400750117 /* DCTConnectionControllerDisplay.m in Sources */, 444 | 2437B5EF15B9775800750117 /* DCTConnectionQueue.m in Sources */, 445 | 2437B5F015B9775D00750117 /* DCTRESTConnectionController.m in Sources */, 446 | 2437B5F115B9776100750117 /* NSString+DCTURLEncoding.m in Sources */, 447 | ); 448 | runOnlyForDeploymentPostprocessing = 0; 449 | }; 450 | 249D6E36159890F300FE9A23 /* Sources */ = { 451 | isa = PBXSourcesBuildPhase; 452 | buildActionMask = 2147483647; 453 | files = ( 454 | 249D6E47159890F300FE9A23 /* main.m in Sources */, 455 | 249D6E4B159890F300FE9A23 /* AppDelegate.m in Sources */, 456 | 247CBC941598FD960006A011 /* ViewController.m in Sources */, 457 | ); 458 | runOnlyForDeploymentPostprocessing = 0; 459 | }; 460 | 24BE260B15A7410100161A59 /* Sources */ = { 461 | isa = PBXSourcesBuildPhase; 462 | buildActionMask = 2147483647; 463 | files = ( 464 | 24BE261E15A7410100161A59 /* main.m in Sources */, 465 | 24BE262515A7410100161A59 /* AppDelegate.m in Sources */, 466 | ); 467 | runOnlyForDeploymentPostprocessing = 0; 468 | }; 469 | 24F6EC47158A2BD200CEDD41 /* Sources */ = { 470 | isa = PBXSourcesBuildPhase; 471 | buildActionMask = 2147483647; 472 | files = ( 473 | 24F6EC5D158A2BD200CEDD41 /* DCTConnectionControllerTests.m in Sources */, 474 | ); 475 | runOnlyForDeploymentPostprocessing = 0; 476 | }; 477 | /* End PBXSourcesBuildPhase section */ 478 | 479 | /* Begin PBXVariantGroup section */ 480 | 249D6E43159890F300FE9A23 /* InfoPlist.strings */ = { 481 | isa = PBXVariantGroup; 482 | children = ( 483 | 249D6E44159890F300FE9A23 /* en */, 484 | ); 485 | name = InfoPlist.strings; 486 | sourceTree = ""; 487 | }; 488 | 24BE261A15A7410100161A59 /* InfoPlist.strings */ = { 489 | isa = PBXVariantGroup; 490 | children = ( 491 | 24BE261B15A7410100161A59 /* en */, 492 | ); 493 | name = InfoPlist.strings; 494 | sourceTree = ""; 495 | }; 496 | 24BE262015A7410100161A59 /* Credits.rtf */ = { 497 | isa = PBXVariantGroup; 498 | children = ( 499 | 24BE262115A7410100161A59 /* en */, 500 | ); 501 | name = Credits.rtf; 502 | sourceTree = ""; 503 | }; 504 | 24BE262615A7410100161A59 /* MainMenu.xib */ = { 505 | isa = PBXVariantGroup; 506 | children = ( 507 | 24BE262715A7410100161A59 /* en */, 508 | ); 509 | name = MainMenu.xib; 510 | sourceTree = ""; 511 | }; 512 | 24F6EC58158A2BD200CEDD41 /* InfoPlist.strings */ = { 513 | isa = PBXVariantGroup; 514 | children = ( 515 | 24F6EC59158A2BD200CEDD41 /* en */, 516 | ); 517 | name = InfoPlist.strings; 518 | sourceTree = ""; 519 | }; 520 | /* End PBXVariantGroup section */ 521 | 522 | /* Begin XCBuildConfiguration section */ 523 | 2437B5E615B9771F00750117 /* Debug */ = { 524 | isa = XCBuildConfiguration; 525 | buildSettings = { 526 | CLANG_CXX_LIBRARY = "libc++"; 527 | DSTROOT = /tmp/DCTConnectionController.dst; 528 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 529 | GCC_PREFIX_HEADER = ""; 530 | IPHONEOS_DEPLOYMENT_TARGET = 5.0; 531 | OTHER_LDFLAGS = "-ObjC"; 532 | PRODUCT_NAME = "$(TARGET_NAME)"; 533 | SKIP_INSTALL = YES; 534 | }; 535 | name = Debug; 536 | }; 537 | 2437B5E715B9771F00750117 /* Release */ = { 538 | isa = XCBuildConfiguration; 539 | buildSettings = { 540 | CLANG_CXX_LIBRARY = "libc++"; 541 | DSTROOT = /tmp/DCTConnectionController.dst; 542 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 543 | GCC_PREFIX_HEADER = ""; 544 | IPHONEOS_DEPLOYMENT_TARGET = 5.0; 545 | OTHER_LDFLAGS = "-ObjC"; 546 | PRODUCT_NAME = "$(TARGET_NAME)"; 547 | SKIP_INSTALL = YES; 548 | }; 549 | name = Release; 550 | }; 551 | 249D6E4C159890F300FE9A23 /* Debug */ = { 552 | isa = XCBuildConfiguration; 553 | buildSettings = { 554 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 555 | FRAMEWORK_SEARCH_PATHS = ( 556 | "$(inherited)", 557 | "\"$(SYSTEM_APPS_DIR)/Xcode45-DP1.app/Contents/Developer/Library/Frameworks\"", 558 | ); 559 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 560 | GCC_PREFIX_HEADER = "iPhone Demo/DCTConnectionControllerDemo-Prefix.pch"; 561 | INFOPLIST_FILE = "iPhone Demo/DCTConnectionControllerDemo-Info.plist"; 562 | IPHONEOS_DEPLOYMENT_TARGET = 5.0; 563 | OTHER_LDFLAGS = ( 564 | "-all_load", 565 | "-ObjC", 566 | ); 567 | PRODUCT_NAME = "$(TARGET_NAME)"; 568 | WRAPPER_EXTENSION = app; 569 | }; 570 | name = Debug; 571 | }; 572 | 249D6E4D159890F300FE9A23 /* Release */ = { 573 | isa = XCBuildConfiguration; 574 | buildSettings = { 575 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 576 | FRAMEWORK_SEARCH_PATHS = ( 577 | "$(inherited)", 578 | "\"$(SYSTEM_APPS_DIR)/Xcode45-DP1.app/Contents/Developer/Library/Frameworks\"", 579 | ); 580 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 581 | GCC_PREFIX_HEADER = "iPhone Demo/DCTConnectionControllerDemo-Prefix.pch"; 582 | INFOPLIST_FILE = "iPhone Demo/DCTConnectionControllerDemo-Info.plist"; 583 | IPHONEOS_DEPLOYMENT_TARGET = 5.0; 584 | OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; 585 | OTHER_LDFLAGS = ( 586 | "-all_load", 587 | "-ObjC", 588 | ); 589 | PRODUCT_NAME = "$(TARGET_NAME)"; 590 | WRAPPER_EXTENSION = app; 591 | }; 592 | name = Release; 593 | }; 594 | 24BE262A15A7410100161A59 /* Debug */ = { 595 | isa = XCBuildConfiguration; 596 | buildSettings = { 597 | COMBINE_HIDPI_IMAGES = YES; 598 | FRAMEWORK_SEARCH_PATHS = ( 599 | "$(inherited)", 600 | "\"$(SYSTEM_APPS_DIR)/Xcode45-DP2.app/Contents/Developer/Library/Frameworks\"", 601 | ); 602 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 603 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 604 | GCC_PREFIX_HEADER = "Mac Demo/Mac Demo-Prefix.pch"; 605 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 606 | INFOPLIST_FILE = "Mac Demo/Mac Demo-Info.plist"; 607 | MACOSX_DEPLOYMENT_TARGET = 10.7; 608 | ONLY_ACTIVE_ARCH = YES; 609 | OTHER_LDFLAGS = ( 610 | "-all_load", 611 | "-ObjC", 612 | ); 613 | PRODUCT_NAME = DCTConnectionController; 614 | SDKROOT = macosx; 615 | WRAPPER_EXTENSION = app; 616 | }; 617 | name = Debug; 618 | }; 619 | 24BE262B15A7410100161A59 /* Release */ = { 620 | isa = XCBuildConfiguration; 621 | buildSettings = { 622 | COMBINE_HIDPI_IMAGES = YES; 623 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 624 | FRAMEWORK_SEARCH_PATHS = ( 625 | "$(inherited)", 626 | "\"$(SYSTEM_APPS_DIR)/Xcode45-DP2.app/Contents/Developer/Library/Frameworks\"", 627 | ); 628 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 629 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 630 | GCC_PREFIX_HEADER = "Mac Demo/Mac Demo-Prefix.pch"; 631 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 632 | INFOPLIST_FILE = "Mac Demo/Mac Demo-Info.plist"; 633 | MACOSX_DEPLOYMENT_TARGET = 10.7; 634 | OTHER_LDFLAGS = ( 635 | "-all_load", 636 | "-ObjC", 637 | ); 638 | PRODUCT_NAME = DCTConnectionController; 639 | SDKROOT = macosx; 640 | WRAPPER_EXTENSION = app; 641 | }; 642 | name = Release; 643 | }; 644 | 24F6EC5E158A2BD200CEDD41 /* Debug */ = { 645 | isa = XCBuildConfiguration; 646 | buildSettings = { 647 | ALWAYS_SEARCH_USER_PATHS = NO; 648 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 649 | CLANG_ENABLE_OBJC_ARC = YES; 650 | CLANG_WARN_BOOL_CONVERSION = YES; 651 | CLANG_WARN_CONSTANT_CONVERSION = YES; 652 | CLANG_WARN_EMPTY_BODY = YES; 653 | CLANG_WARN_ENUM_CONVERSION = YES; 654 | CLANG_WARN_INT_CONVERSION = YES; 655 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 656 | COPY_PHASE_STRIP = NO; 657 | GCC_C_LANGUAGE_STANDARD = gnu99; 658 | GCC_DYNAMIC_NO_PIC = NO; 659 | GCC_OPTIMIZATION_LEVEL = 0; 660 | GCC_PREPROCESSOR_DEFINITIONS = ( 661 | "DEBUG=1", 662 | "$(inherited)", 663 | ); 664 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 665 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 666 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 667 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 668 | GCC_WARN_UNDECLARED_SELECTOR = YES; 669 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 670 | GCC_WARN_UNUSED_FUNCTION = YES; 671 | GCC_WARN_UNUSED_VARIABLE = YES; 672 | IPHONEOS_DEPLOYMENT_TARGET = 5.1; 673 | ONLY_ACTIVE_ARCH = YES; 674 | SDKROOT = iphoneos; 675 | }; 676 | name = Debug; 677 | }; 678 | 24F6EC5F158A2BD200CEDD41 /* Release */ = { 679 | isa = XCBuildConfiguration; 680 | buildSettings = { 681 | ALWAYS_SEARCH_USER_PATHS = NO; 682 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 683 | CLANG_ENABLE_OBJC_ARC = YES; 684 | CLANG_WARN_BOOL_CONVERSION = YES; 685 | CLANG_WARN_CONSTANT_CONVERSION = YES; 686 | CLANG_WARN_EMPTY_BODY = YES; 687 | CLANG_WARN_ENUM_CONVERSION = YES; 688 | CLANG_WARN_INT_CONVERSION = YES; 689 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 690 | COPY_PHASE_STRIP = YES; 691 | GCC_C_LANGUAGE_STANDARD = gnu99; 692 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 693 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 694 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 695 | GCC_WARN_UNDECLARED_SELECTOR = YES; 696 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 697 | GCC_WARN_UNUSED_FUNCTION = YES; 698 | GCC_WARN_UNUSED_VARIABLE = YES; 699 | IPHONEOS_DEPLOYMENT_TARGET = 5.1; 700 | SDKROOT = iphoneos; 701 | VALIDATE_PRODUCT = YES; 702 | }; 703 | name = Release; 704 | }; 705 | 24F6EC64158A2BD200CEDD41 /* Debug */ = { 706 | isa = XCBuildConfiguration; 707 | buildSettings = { 708 | FRAMEWORK_SEARCH_PATHS = ( 709 | "\"$(SDKROOT)/Developer/Library/Frameworks\"", 710 | "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"", 711 | ); 712 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 713 | GCC_PREFIX_HEADER = "DCTConnectionController/DCTConnectionController-Prefix.pch"; 714 | INFOPLIST_FILE = "DCTConnectionControllerTests/DCTConnectionControllerTests-Info.plist"; 715 | PRODUCT_NAME = "$(TARGET_NAME)"; 716 | WRAPPER_EXTENSION = octest; 717 | }; 718 | name = Debug; 719 | }; 720 | 24F6EC65158A2BD200CEDD41 /* Release */ = { 721 | isa = XCBuildConfiguration; 722 | buildSettings = { 723 | FRAMEWORK_SEARCH_PATHS = ( 724 | "\"$(SDKROOT)/Developer/Library/Frameworks\"", 725 | "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"", 726 | ); 727 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 728 | GCC_PREFIX_HEADER = "DCTConnectionController/DCTConnectionController-Prefix.pch"; 729 | INFOPLIST_FILE = "DCTConnectionControllerTests/DCTConnectionControllerTests-Info.plist"; 730 | PRODUCT_NAME = "$(TARGET_NAME)"; 731 | WRAPPER_EXTENSION = octest; 732 | }; 733 | name = Release; 734 | }; 735 | /* End XCBuildConfiguration section */ 736 | 737 | /* Begin XCConfigurationList section */ 738 | 2437B5E515B9771F00750117 /* Build configuration list for PBXNativeTarget "DCTConnectionController" */ = { 739 | isa = XCConfigurationList; 740 | buildConfigurations = ( 741 | 2437B5E615B9771F00750117 /* Debug */, 742 | 2437B5E715B9771F00750117 /* Release */, 743 | ); 744 | defaultConfigurationIsVisible = 0; 745 | defaultConfigurationName = Release; 746 | }; 747 | 249D6E4E159890F300FE9A23 /* Build configuration list for PBXNativeTarget "iPhone Demo" */ = { 748 | isa = XCConfigurationList; 749 | buildConfigurations = ( 750 | 249D6E4C159890F300FE9A23 /* Debug */, 751 | 249D6E4D159890F300FE9A23 /* Release */, 752 | ); 753 | defaultConfigurationIsVisible = 0; 754 | defaultConfigurationName = Release; 755 | }; 756 | 24BE262915A7410100161A59 /* Build configuration list for PBXNativeTarget "Mac Demo" */ = { 757 | isa = XCConfigurationList; 758 | buildConfigurations = ( 759 | 24BE262A15A7410100161A59 /* Debug */, 760 | 24BE262B15A7410100161A59 /* Release */, 761 | ); 762 | defaultConfigurationIsVisible = 0; 763 | defaultConfigurationName = Release; 764 | }; 765 | 24F6EC36158A2BD100CEDD41 /* Build configuration list for PBXProject "DCTConnectionController" */ = { 766 | isa = XCConfigurationList; 767 | buildConfigurations = ( 768 | 24F6EC5E158A2BD200CEDD41 /* Debug */, 769 | 24F6EC5F158A2BD200CEDD41 /* Release */, 770 | ); 771 | defaultConfigurationIsVisible = 0; 772 | defaultConfigurationName = Release; 773 | }; 774 | 24F6EC63158A2BD200CEDD41 /* Build configuration list for PBXNativeTarget "DCTConnectionControllerTests" */ = { 775 | isa = XCConfigurationList; 776 | buildConfigurations = ( 777 | 24F6EC64158A2BD200CEDD41 /* Debug */, 778 | 24F6EC65158A2BD200CEDD41 /* Release */, 779 | ); 780 | defaultConfigurationIsVisible = 0; 781 | defaultConfigurationName = Release; 782 | }; 783 | /* End XCConfigurationList section */ 784 | }; 785 | rootObject = 24F6EC33158A2BD100CEDD41 /* Project object */; 786 | } 787 | -------------------------------------------------------------------------------- /DCTConnectionController.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /DCTConnectionController/DCTConnectionController+BlockHandlers.h: -------------------------------------------------------------------------------- 1 | // 2 | // DCTConnectionController+BlockHandlers.h 3 | // DCTConnectionController 4 | // 5 | // Created by Daniel Tull on 09.12.2011. 6 | // Copyright (c) 2011 Daniel Tull. All rights reserved. 7 | // 8 | 9 | #import "DCTConnectionController.h" 10 | 11 | @interface DCTConnectionController (BlockHandlers) 12 | 13 | /// @name Event Blocks 14 | 15 | /** Adds a block that is called when the connection controller receives a response. 16 | 17 | If the connection controller has already received a response, this block is called 18 | straight away. 19 | 20 | @param responseHandler The response block to add. 21 | */ 22 | - (void)addResponseHandler:(void(^)(NSURLResponse *response))responseHandler; 23 | 24 | /** Adds a block that is called when the connection controller successfully finishes. 25 | 26 | If the connection controller has already finished, this block is called 27 | straight away. 28 | 29 | @param finishHandler The completion block to add. 30 | */ 31 | - (void)addCompletionHandler:(void(^)())completionHandler; 32 | 33 | /** Adds a block that is called when the connection controller fails. 34 | 35 | If the connection controller has already failed, this block is called 36 | straight away. 37 | 38 | @param failureHandler The failure block to add. 39 | */ 40 | - (void)addFailureHandler:(void(^)(NSError *error))failureHandler; 41 | 42 | /** Adds a block that is called when the connection controller is cancelled. 43 | 44 | If the connection controller has already been cancelled, this block is called 45 | straight away. 46 | 47 | @param cancelationHandler The cancelation block to add. 48 | */ 49 | - (void)addCancelationHandler:(void(^)())cancelationHandler; 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /DCTConnectionController/DCTConnectionController+BlockHandlers.m: -------------------------------------------------------------------------------- 1 | // 2 | // DCTConnectionController+BlockHandlers.m 3 | // DCTConnectionController 4 | // 5 | // Created by Daniel Tull on 09.12.2011. 6 | // Copyright (c) 2011 Daniel Tull. All rights reserved. 7 | // 8 | 9 | #import "DCTConnectionController+BlockHandlers.h" 10 | 11 | @implementation DCTConnectionController (BlockHandlers) 12 | 13 | - (void)addResponseHandler:(void (^)(NSURLResponse *))responseHandler { 14 | 15 | NSAssert(responseHandler != nil, @"Handler should not be nil."); 16 | 17 | if (self.status >= DCTConnectionControllerStatusResponded) { 18 | responseHandler(self.returnedResponse); 19 | return; 20 | } 21 | 22 | __weak DCTConnectionController *weakSelf = self; 23 | 24 | [self addStatusChangeHandler:^(DCTConnectionControllerStatus status) { 25 | if (status == DCTConnectionControllerStatusResponded) 26 | responseHandler(weakSelf.returnedResponse); 27 | }]; 28 | } 29 | 30 | - (void)addCompletionHandler:(void (^)())completionHandler { 31 | 32 | NSAssert(completionHandler != NULL, @"Handler should not be nil."); 33 | 34 | if (self.status == DCTConnectionControllerStatusCompleted) { 35 | completionHandler(); 36 | return; 37 | } 38 | 39 | [self addStatusChangeHandler:^(DCTConnectionControllerStatus status) { 40 | if (status == DCTConnectionControllerStatusCompleted) 41 | completionHandler(); 42 | }]; 43 | } 44 | 45 | - (void)addFailureHandler:(void (^)(NSError *))failureHandler { 46 | 47 | NSAssert(failureHandler != nil, @"Handler should not be nil."); 48 | 49 | if (self.status == DCTConnectionControllerStatusFailed) { 50 | failureHandler(self.returnedError); 51 | return; 52 | } 53 | 54 | __weak DCTConnectionController *weakSelf = self; 55 | 56 | [self addStatusChangeHandler:^(DCTConnectionControllerStatus status) { 57 | if (status == DCTConnectionControllerStatusFailed) 58 | failureHandler(weakSelf.returnedError); 59 | }]; 60 | } 61 | 62 | - (void)addCancelationHandler:(void (^)())cancelationHandler { 63 | 64 | NSAssert(cancelationHandler != nil, @"Handler should not be nil."); 65 | 66 | if (self.status == DCTConnectionControllerStatusCancelled) { 67 | cancelationHandler(); 68 | return; 69 | } 70 | 71 | [self addStatusChangeHandler:^(DCTConnectionControllerStatus status) { 72 | if (status == DCTConnectionControllerStatusCancelled) 73 | cancelationHandler(); 74 | }]; 75 | } 76 | 77 | @end 78 | -------------------------------------------------------------------------------- /DCTConnectionController/DCTConnectionController+Equality.h: -------------------------------------------------------------------------------- 1 | /* 2 | DCTConnectionController+Equality.h 3 | DCTConnectionController 4 | 5 | Created by Daniel Tull on 9.11.2010. 6 | 7 | 8 | 9 | Copyright (c) 2010 Daniel Tull. All rights reserved. 10 | 11 | Redistribution and use in source and binary forms, with or without 12 | modification, are permitted provided that the following conditions are met: 13 | 14 | * Redistributions of source code must retain the above copyright notice, this 15 | list of conditions and the following disclaimer. 16 | 17 | * Redistributions in binary form must reproduce the above copyright notice, 18 | this list of conditions and the following disclaimer in the documentation 19 | and/or other materials provided with the distribution. 20 | 21 | * Neither the name of the author nor the names of its contributors may be used 22 | to endorse or promote products derived from this software without specific 23 | prior written permission. 24 | 25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | #import 38 | #import "DCTConnectionController.h" 39 | 40 | @interface DCTConnectionController (Equality) 41 | 42 | /// @name Checking for Equality 43 | 44 | /** Determines whether the given connection controller is equal to the receiver. 45 | 46 | Connection controllers are determined equal by checking the URL , the type and 47 | their properties for equality. 48 | 49 | @param connectionController The connection controller to check equality with. 50 | @return YES if the connection controllers are equal. 51 | */ 52 | - (BOOL)isEqualToConnectionController:(DCTConnectionController *)connectionController; 53 | @end 54 | -------------------------------------------------------------------------------- /DCTConnectionController/DCTConnectionController+Equality.m: -------------------------------------------------------------------------------- 1 | /* 2 | DCTConnectionController+Equality.m 3 | DCTConnectionController 4 | 5 | Created by Daniel Tull on 9.11.2010. 6 | 7 | 8 | 9 | Copyright (c) 2010 Daniel Tull. All rights reserved. 10 | 11 | Redistribution and use in source and binary forms, with or without 12 | modification, are permitted provided that the following conditions are met: 13 | 14 | * Redistributions of source code must retain the above copyright notice, this 15 | list of conditions and the following disclaimer. 16 | 17 | * Redistributions in binary form must reproduce the above copyright notice, 18 | this list of conditions and the following disclaimer in the documentation 19 | and/or other materials provided with the distribution. 20 | 21 | * Neither the name of the author nor the names of its contributors may be used 22 | to endorse or promote products derived from this software without specific 23 | prior written permission. 24 | 25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | #import "DCTConnectionController+Equality.h" 38 | #import 39 | 40 | @interface DCTConnectionController (EqualityInternal) 41 | - (NSArray *)dctEqualityInternal_propertiesOfClass:(Class)class; 42 | - (NSArray *)dctEqualityInternal_properties; 43 | @end 44 | 45 | @implementation DCTConnectionController (Equality) 46 | 47 | - (BOOL)isEqualToConnectionController:(DCTConnectionController *)connectionController { 48 | 49 | if (![connectionController isKindOfClass:[self class]]) return NO; 50 | 51 | if (connectionController.type != self.type) return NO; 52 | 53 | if (![connectionController.URLRequest.URL isEqual:self.URLRequest.URL]) return NO; 54 | 55 | NSArray *properties = [self dctEqualityInternal_properties]; 56 | 57 | for (NSString *key in properties) { 58 | 59 | id selfObject = [self valueForKey:key]; 60 | id connectionControllerObject = [connectionController valueForKey:key]; 61 | 62 | if (![selfObject isEqual:connectionControllerObject]) return NO; 63 | } 64 | 65 | return YES; 66 | } 67 | 68 | @end 69 | 70 | @implementation DCTConnectionController (EqualityInternal) 71 | 72 | - (NSArray *)dctEqualityInternal_properties { 73 | 74 | Class aClass = [self class]; 75 | 76 | NSMutableArray *array = [[NSMutableArray alloc] init]; 77 | 78 | while ([aClass isSubclassOfClass:[DCTConnectionController class]] 79 | && ![DCTConnectionController isSubclassOfClass:aClass]) { 80 | 81 | [array addObjectsFromArray:[self dctEqualityInternal_propertiesOfClass:aClass]]; 82 | aClass = [aClass superclass]; 83 | } 84 | 85 | return array; 86 | } 87 | 88 | - (NSArray *)dctEqualityInternal_propertiesOfClass:(Class)class { 89 | 90 | NSMutableArray *array = [[NSMutableArray alloc] init]; 91 | 92 | unsigned int outCount; 93 | 94 | objc_property_t *properties = class_copyPropertyList(class, &outCount); 95 | 96 | for (NSUInteger i = 0; i < outCount; i++) { 97 | objc_property_t property = properties[i]; 98 | const char *propertyName = property_getName(property); 99 | NSString *nameString = [[NSString alloc] initWithCString:propertyName encoding:NSUTF8StringEncoding]; 100 | [array addObject:nameString]; 101 | } 102 | 103 | free(properties); 104 | 105 | return array; 106 | 107 | } 108 | 109 | @end 110 | -------------------------------------------------------------------------------- /DCTConnectionController/DCTConnectionController.h: -------------------------------------------------------------------------------- 1 | /* 2 | DCTConnectionController.h 3 | DCTConnectionController 4 | 5 | Created by Daniel Tull on 9.6.2010. 6 | 7 | 8 | 9 | Copyright (c) 2010 Daniel Tull. All rights reserved. 10 | 11 | Redistribution and use in source and binary forms, with or without 12 | modification, are permitted provided that the following conditions are met: 13 | 14 | * Redistributions of source code must retain the above copyright notice, this 15 | list of conditions and the following disclaimer. 16 | 17 | * Redistributions in binary form must reproduce the above copyright notice, 18 | this list of conditions and the following disclaimer in the documentation 19 | and/or other materials provided with the distribution. 20 | 21 | * Neither the name of the author nor the names of its contributors may be used 22 | to endorse or promote products derived from this software without specific 23 | prior written permission. 24 | 25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | #import 38 | 39 | #ifndef dctconnectioncontroller 40 | #define dctconnectioncontroller_1_0 10000 41 | #define dctconnectioncontroller_2_0 20000 42 | #define dctconnectioncontroller_2_0_1 20001 43 | #define dctconnectioncontroller_2_1 20100 44 | #define dctconnectioncontroller_2_2 20200 45 | #define dctconnectioncontroller dctconnectioncontroller_2_2 46 | #endif 47 | 48 | @class DCTConnectionQueue; 49 | 50 | /** Specifies the type of connection to use. 51 | */ 52 | typedef enum : NSInteger { 53 | DCTConnectionControllerTypeGet = 0, /**< Uses a GET connection. */ 54 | DCTConnectionControllerTypePost, /**< Uses a POST connection. */ 55 | DCTConnectionControllerTypePut, /**< Uses a PUT connection. */ 56 | DCTConnectionControllerTypeDelete, /**< Uses a DELETE connection. */ 57 | DCTConnectionControllerTypeOptions, /**< Uses a OPTIONS connection. */ 58 | DCTConnectionControllerTypeHead, /**< Uses a HEAD connection. */ 59 | DCTConnectionControllerTypeTrace, /**< Uses a TRACE connection. */ 60 | DCTConnectionControllerTypeConnect, 61 | DCTConnectionControllerTypePatch 62 | } DCTConnectionControllerType; 63 | 64 | /** Specifies the different stages of a connection. 65 | */ 66 | typedef enum : NSInteger { 67 | DCTConnectionControllerStatusNotStarted = 0, /**< The connection has not begun yet, and has not been given to the DTConnectionManager object to perform. */ 68 | DCTConnectionControllerStatusQueued, /**< The connection has been placed in a queue and is awaiting a free slot to perform. */ 69 | DCTConnectionControllerStatusStarted, /**< The request has been sent and a response is being awaited. */ 70 | DCTConnectionControllerStatusResponded, /**< A response has been received by the server and the connection is awaiting completion. */ 71 | DCTConnectionControllerStatusCompleted, /**< The connection completed without any errors. */ 72 | DCTConnectionControllerStatusFailed, /**< The connection failed. */ 73 | DCTConnectionControllerStatusCancelled, /**< The connection was cancelled. */ 74 | } DCTConnectionControllerStatus; 75 | 76 | /** Specifies the possible priorities for a connection. 77 | */ 78 | typedef enum : NSInteger { 79 | DCTConnectionControllerPriorityVeryHigh = NSOperationQueuePriorityVeryHigh, 80 | DCTConnectionControllerPriorityHigh = NSOperationQueuePriorityHigh, 81 | DCTConnectionControllerPriorityMedium = NSOperationQueuePriorityNormal, 82 | DCTConnectionControllerPriorityLow = NSOperationQueuePriorityLow, 83 | DCTConnectionControllerPriorityVeryLow = NSOperationQueuePriorityVeryLow 84 | } DCTConnectionControllerPriority; 85 | 86 | /** Name of the notification sent out when the connection has successfully completed. 87 | */ 88 | extern NSString *const DCTConnectionControllerDidCompleteNotification; 89 | 90 | /** Name of the notification sent out when the connection has failed. 91 | */ 92 | extern NSString *const DCTConnectionControllerDidFailNotification; 93 | 94 | /** Name of the notification sent out when the connection has recieved a response. 95 | */ 96 | extern NSString *const DCTConnectionControllerDidReceiveResponseNotification; 97 | 98 | extern NSString *const DCTConnectionControllerWasCancelledNotification; 99 | 100 | extern NSString *const DCTConnectionControllerStatusChangedNotification; 101 | 102 | extern NSString *const DCTConnectionControllerTypeString[]; 103 | 104 | @interface DCTConnectionController : NSOperation 105 | 106 | @property (nonatomic, assign) DCTConnectionControllerType type; 107 | @property (nonatomic, assign) DCTConnectionControllerPriority priority; 108 | @property (nonatomic, strong) NSURLRequest *URLRequest; 109 | 110 | - (id)initWithURLRequest:(NSURLRequest *)URLRequest; 111 | 112 | - (void)performBlock:(void(^)())block; 113 | 114 | #pragma mark - Managing the Connection 115 | 116 | - (void)enqueue; 117 | - (void)enqueueOnQueue:(DCTConnectionQueue *)queue; 118 | 119 | #pragma mark - Methods to use in Subclasses 120 | 121 | - (void)loadURLRequest; 122 | - (void)connectionDidReceiveResponse; 123 | - (void)connectionDidFinishLoading; 124 | - (void)connectionDidFail; 125 | 126 | #pragma mark - Connection Status 127 | 128 | @property (nonatomic, strong) id returnedObject; 129 | @property (nonatomic, strong) NSError *returnedError; 130 | @property (nonatomic, readonly) NSURLResponse *returnedResponse; 131 | @property (nonatomic, readonly) NSString *downloadPath; 132 | 133 | @property (nonatomic, readonly) DCTConnectionControllerStatus status; 134 | - (void)addStatusChangeHandler:(void(^)(DCTConnectionControllerStatus status))handler; 135 | 136 | - (NSString *)fullDescription; 137 | 138 | 139 | 140 | 141 | 142 | /* 143 | @property (nonatomic, strong, readonly) NSNumber *percentDownloaded; 144 | - (void)addPercentDownloadedChangeHandler:(void(^)(NSNumber *percentDownloaded))handler; 145 | */ 146 | 147 | @property (nonatomic, readonly) DCTConnectionQueue *connectionQueue; 148 | 149 | @end 150 | 151 | #import "DCTConnectionController+BlockHandlers.h" 152 | #import "DCTRESTConnectionController.h" 153 | #import "DCTConnectionQueue.h" 154 | -------------------------------------------------------------------------------- /DCTConnectionController/DCTConnectionController.m: -------------------------------------------------------------------------------- 1 | /* 2 | DCTConnectionController.m 3 | DCTConnectionController 4 | 5 | Created by Daniel Tull on 9.6.2010. 6 | 7 | 8 | 9 | Copyright (c) 2010 Daniel Tull. All rights reserved. 10 | 11 | Redistribution and use in source and binary forms, with or without 12 | modification, are permitted provided that the following conditions are met: 13 | 14 | * Redistributions of source code must retain the above copyright notice, this 15 | list of conditions and the following disclaimer. 16 | 17 | * Redistributions in binary form must reproduce the above copyright notice, 18 | this list of conditions and the following disclaimer in the documentation 19 | and/or other materials provided with the distribution. 20 | 21 | * Neither the name of the author nor the names of its contributors may be used 22 | to endorse or promote products derived from this software without specific 23 | prior written permission. 24 | 25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | #import "DCTConnectionController.h" 38 | #import "DCTConnectionController+Equality.h" 39 | #import "DCTRESTConnectionController.h" 40 | #import "_DCTConnectionQueue.h" 41 | 42 | NSString * const DCTInternalConnectionControllerStatusString[] = { 43 | @"NotStarted", 44 | @"Queued", 45 | @"Started", 46 | @"Responded", 47 | @"Finished", 48 | @"Failed", 49 | @"Cancelled" 50 | }; 51 | 52 | NSString * const DCTInternalConnectionControllerPriorityString[] = { 53 | @"VeryHigh", 54 | @"High", 55 | @"Medium", 56 | @"Low", 57 | @"VeryLow" 58 | }; 59 | 60 | NSString * const DCTInternalConnectionControllerTypeString[] = { 61 | @"GET", 62 | @"POST", 63 | @"PUT", 64 | @"DELETE", 65 | @"OPTIONS", 66 | @"HEAD", 67 | @"TRACE", 68 | @"CONNECT", 69 | @"PATCH" 70 | }; 71 | 72 | NSString *const DCTConnectionControllerDidCompleteNotification = @"DCTConnectionControllerDidCompleteNotification"; 73 | NSString *const DCTConnectionControllerDidFailNotification = @"DCTConnectionControllerDidFailNotification"; 74 | NSString *const DCTConnectionControllerDidReceiveResponseNotification = @"DCTConnectionControllerDidReceiveResponseNotification"; 75 | NSString *const DCTConnectionControllerWasCancelledNotification = @"DCTConnectionControllerWasCancelledNotification"; 76 | NSString *const DCTConnectionControllerStatusChangedNotification = @"DCTConnectionControllerStatusChangedNotification"; 77 | 78 | BOOL DCTConnectionControllerCanSetDelegateQueue() { 79 | 80 | Class collectionViewClass = NSClassFromString(@"UICollectionView"); 81 | Class tableViewClass = NSClassFromString(@"UITableView"); 82 | 83 | if (tableViewClass && !collectionViewClass) return NO; 84 | 85 | return YES; 86 | } 87 | 88 | BOOL DCTConnectionControllerStatusIsExecuting(DCTConnectionControllerStatus status) { 89 | return (status >= DCTConnectionControllerStatusStarted && status <= DCTConnectionControllerStatusResponded); 90 | } 91 | 92 | BOOL DCTConnectionControllerStatusIsFinished(DCTConnectionControllerStatus status) { 93 | return (status > DCTConnectionControllerStatusResponded); 94 | } 95 | 96 | BOOL DCTConnectionControllerStatusIsQueued(DCTConnectionControllerStatus status) { 97 | return (status == DCTConnectionControllerStatusQueued); 98 | } 99 | 100 | @implementation DCTConnectionController { 101 | __weak DCTConnectionQueue *_connectionQueue; 102 | __strong NSOperationQueue *_operationQueue; 103 | __strong NSMutableSet *_statusChangeBlocks; 104 | __strong NSMutableSet *_statusWillChangeBlocks; 105 | __strong NSFileHandle *_fileHandle; 106 | __strong NSFileManager *_fileManager; 107 | __strong NSURLConnection *_URLConnection; 108 | __strong NSString *_downloadPath; 109 | __strong NSURLResponse *_returnedResponse; 110 | BOOL _isReturnedObjectLoaded; 111 | } 112 | 113 | + (NSString *)path { 114 | NSString *temporaryDirectory = NSTemporaryDirectory(); 115 | return [temporaryDirectory stringByAppendingPathComponent:@"DCTConnectionController"]; 116 | } 117 | 118 | + (void)load { 119 | @autoreleasepool { 120 | NSError *error = nil; 121 | if (![[NSFileManager defaultManager] createDirectoryAtPath:[self path] 122 | withIntermediateDirectories:YES 123 | attributes:nil 124 | error:&error]) 125 | NSLog(@"%@:%@ %@", self, NSStringFromSelector(_cmd), [error localizedDescription]); 126 | } 127 | } 128 | 129 | - (void)dealloc { 130 | [_fileManager removeItemAtPath:self.downloadPath error:nil]; 131 | _fileManager = nil; 132 | } 133 | 134 | - (void)setPriority:(DCTConnectionControllerPriority)priority { 135 | self.queuePriority = (NSOperationQueuePriority)priority; 136 | } 137 | 138 | - (DCTConnectionControllerPriority)priority { 139 | return (DCTConnectionControllerPriority)self.queuePriority; 140 | } 141 | 142 | - (BOOL)isConcurrent { 143 | return YES; 144 | } 145 | 146 | - (BOOL)isExecuting { 147 | return DCTConnectionControllerStatusIsExecuting(self.status); 148 | } 149 | 150 | - (BOOL)isFinished { 151 | return DCTConnectionControllerStatusIsFinished(self.status); 152 | } 153 | 154 | #pragma mark - NSCoding 155 | 156 | - (id)initWithCoder:(NSCoder *)coder { 157 | if (!(self = [self init])) return nil; 158 | self.type = [coder decodeIntegerForKey:NSStringFromSelector(@selector(type))]; 159 | self.priority = [coder decodeIntegerForKey:NSStringFromSelector(@selector(priority))]; 160 | return self; 161 | } 162 | 163 | - (void)encodeWithCoder:(NSCoder *)coder { 164 | [coder encodeInteger:self.type forKey:NSStringFromSelector(@selector(type))]; 165 | [coder encodeInteger:self.priority forKey:NSStringFromSelector(@selector(priority))]; 166 | } 167 | 168 | - (id)initWithURLRequest:(NSURLRequest *)URLRequest { 169 | self = [self init]; 170 | if (!self) return nil; 171 | _URLRequest = [URLRequest copy]; 172 | return self; 173 | } 174 | 175 | - (void)performBlock:(void(^)())block { 176 | [_operationQueue addOperationWithBlock:block]; 177 | } 178 | 179 | - (id)init { 180 | if (!(self = [super init])) return nil; 181 | 182 | _operationQueue = [NSOperationQueue new]; 183 | [_operationQueue setMaxConcurrentOperationCount:1]; 184 | [_operationQueue setName:@"DCTConnectionController Queue"]; 185 | 186 | [self performBlock:^{ 187 | _statusChangeBlocks = [NSMutableSet new]; 188 | _fileManager = [NSFileManager new]; 189 | }]; 190 | 191 | __weak DCTConnectionController *weakSelf = self; 192 | 193 | [self addStatusChangeHandler:^(DCTConnectionControllerStatus status) { 194 | 195 | [[NSOperationQueue mainQueue] addOperationWithBlock:^{ 196 | 197 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 198 | 199 | [notificationCenter postNotificationName:DCTConnectionControllerStatusChangedNotification object:weakSelf]; 200 | 201 | switch (status) { 202 | 203 | case DCTConnectionControllerStatusResponded: 204 | [notificationCenter postNotificationName:DCTConnectionControllerDidReceiveResponseNotification object:weakSelf]; 205 | break; 206 | 207 | case DCTConnectionControllerStatusCancelled: 208 | [notificationCenter postNotificationName:DCTConnectionControllerWasCancelledNotification object:weakSelf]; 209 | break; 210 | 211 | case DCTConnectionControllerStatusCompleted: 212 | [notificationCenter postNotificationName:DCTConnectionControllerDidCompleteNotification object:weakSelf]; 213 | break; 214 | 215 | case DCTConnectionControllerStatusFailed: 216 | [notificationCenter postNotificationName:DCTConnectionControllerDidFailNotification object:weakSelf]; 217 | break; 218 | 219 | default: 220 | break; 221 | } 222 | }]; 223 | }]; 224 | 225 | return self; 226 | } 227 | 228 | - (void)enqueue { 229 | [self enqueueOnQueue:[DCTConnectionQueue defaultConnectionQueue]]; 230 | } 231 | 232 | - (void)enqueueOnQueue:(DCTConnectionQueue *)connectionQueue { 233 | 234 | if (self.status > DCTConnectionControllerStatusNotStarted) return; 235 | 236 | _connectionQueue = connectionQueue; 237 | 238 | [self performBlock:^{ 239 | 240 | NSUInteger existingConnectionControllerIndex = [_connectionQueue.connectionControllers indexOfObject:self]; 241 | 242 | if (existingConnectionControllerIndex == NSNotFound) { 243 | [_connectionQueue _addOperation:self]; 244 | [self setStatus:DCTConnectionControllerStatusQueued]; 245 | return; 246 | } 247 | 248 | DCTConnectionController *existingConnectionController = [_connectionQueue.connectionControllers objectAtIndex:existingConnectionControllerIndex]; 249 | 250 | // If it's the exact same object, lets not add it again. This could happen if -connectOnQueue: is called more than once. 251 | if (existingConnectionController == self) return; 252 | 253 | // Not sure why it's this way around. 254 | if (existingConnectionController.priority > self.priority) 255 | existingConnectionController.priority = self.priority; 256 | 257 | self.status = existingConnectionController.status; 258 | 259 | __weak DCTConnectionController *weakExistingConnectionController = existingConnectionController; 260 | 261 | [existingConnectionController addStatusChangeHandler:^(DCTConnectionControllerStatus status) { 262 | 263 | __strong DCTConnectionController *strongExistingConnectionController = weakExistingConnectionController; 264 | 265 | switch (status) { 266 | 267 | case DCTConnectionControllerStatusResponded: 268 | _returnedResponse = strongExistingConnectionController.returnedResponse; 269 | break; 270 | 271 | case DCTConnectionControllerStatusCompleted: 272 | _downloadPath = strongExistingConnectionController.downloadPath; 273 | if (strongExistingConnectionController->_isReturnedObjectLoaded) 274 | _returnedObject = strongExistingConnectionController.returnedObject; 275 | break; 276 | 277 | case DCTConnectionControllerStatusFailed: 278 | _returnedError = strongExistingConnectionController.returnedError; 279 | break; 280 | 281 | default: 282 | break; 283 | } 284 | 285 | [self setStatus:status]; 286 | }]; 287 | }]; 288 | } 289 | 290 | - (void)start { 291 | 292 | if (self.status >= DCTConnectionControllerStatusStarted) return; 293 | [self setStatus:DCTConnectionControllerStatusStarted]; 294 | 295 | [self performBlock:^{ 296 | 297 | _URLConnection = [[NSURLConnection alloc] initWithRequest:self.URLRequest delegate:self startImmediately:NO]; 298 | 299 | if (DCTConnectionControllerCanSetDelegateQueue()) 300 | [_URLConnection setDelegateQueue:_operationQueue]; 301 | 302 | [_URLConnection start]; 303 | 304 | if (!DCTConnectionControllerCanSetDelegateQueue()) 305 | CFRunLoopRun(); 306 | 307 | if (!_URLConnection) 308 | [self performBlock:^{ 309 | // TODO: GENERATE ERROR 310 | [self connectionDidFail]; 311 | }]; 312 | }]; 313 | } 314 | 315 | - (NSURLRequest *)URLRequest { 316 | 317 | if (!_URLRequest) [self loadURLRequest]; 318 | 319 | return _URLRequest; 320 | } 321 | 322 | #pragma mark - Subclass Methods 323 | 324 | - (void)loadURLRequest { 325 | NSMutableURLRequest *request = [NSMutableURLRequest new]; 326 | [request setHTTPMethod:DCTInternalConnectionControllerTypeString[self.type]]; 327 | self.URLRequest = request; 328 | } 329 | 330 | - (void)connectionDidFinishLoading { 331 | [self setStatus:DCTConnectionControllerStatusCompleted]; 332 | } 333 | 334 | - (void)connectionDidReceiveResponse { 335 | [self setStatus:DCTConnectionControllerStatusResponded]; 336 | } 337 | 338 | - (void)connectionDidFail { 339 | [self setStatus:DCTConnectionControllerStatusFailed]; 340 | } 341 | 342 | - (id)returnedObject { 343 | 344 | if (!_returnedObject) { 345 | _returnedObject = [[NSData alloc] initWithContentsOfFile:self.downloadPath]; 346 | _isReturnedObjectLoaded = YES; 347 | } 348 | return _returnedObject; 349 | } 350 | 351 | - (NSString *)downloadPath { 352 | 353 | if (!_downloadPath) 354 | _downloadPath = [[[self class] path] stringByAppendingPathComponent:[[NSProcessInfo processInfo] globallyUniqueString]]; 355 | 356 | return _downloadPath; 357 | } 358 | 359 | - (NSURLResponse *)returnedResponse { 360 | return _returnedResponse; 361 | } 362 | 363 | - (void)setStatus:(DCTConnectionControllerStatus)newStatus { 364 | 365 | [self performBlock:^{ 366 | 367 | DCTConnectionControllerStatus oldStatus = _status; 368 | 369 | if (newStatus <= oldStatus 370 | && newStatus != DCTConnectionControllerStatusNotStarted 371 | && newStatus != DCTConnectionControllerStatusQueued) 372 | return; 373 | 374 | if (DCTConnectionControllerStatusIsFinished(oldStatus)) return; 375 | 376 | if (DCTConnectionControllerStatusIsQueued(oldStatus) && DCTConnectionControllerStatusIsExecuting(newStatus)) 377 | [self willChangeValueForKey:@"isExecuting"]; 378 | 379 | if (DCTConnectionControllerStatusIsFinished(newStatus)) { 380 | [self willChangeValueForKey:@"isExecuting"]; 381 | [self willChangeValueForKey:@"isFinished"]; 382 | } 383 | 384 | [self willChangeValueForKey:@"status"]; 385 | _status = newStatus; 386 | [self didChangeValueForKey:@"status"]; 387 | 388 | if (DCTConnectionControllerStatusIsQueued(oldStatus) && DCTConnectionControllerStatusIsExecuting(newStatus)) 389 | [self didChangeValueForKey:@"isExecuting"]; 390 | 391 | if (DCTConnectionControllerStatusIsFinished(newStatus)) { 392 | [self didChangeValueForKey:@"isExecuting"]; 393 | [self didChangeValueForKey:@"isFinished"]; 394 | } 395 | 396 | [_statusChangeBlocks enumerateObjectsUsingBlock:^(void(^block)(DCTConnectionControllerStatus), BOOL *stop) { 397 | block(_status); 398 | }]; 399 | }]; 400 | } 401 | 402 | - (void)addStatusChangeHandler:(void(^)(DCTConnectionControllerStatus status))handler { 403 | NSAssert(handler != NULL, @"Handler is NULL."); 404 | [self performBlock:^{ 405 | [_statusChangeBlocks addObject:handler]; 406 | }]; 407 | } 408 | 409 | #pragma mark - NSURLConnectionDelegate 410 | 411 | - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { 412 | _returnedResponse = response; 413 | [self connectionDidReceiveResponse]; 414 | } 415 | 416 | - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { 417 | 418 | if (!_fileHandle) { 419 | 420 | NSString *downloadPath = self.downloadPath; 421 | 422 | if ([_fileManager fileExistsAtPath:downloadPath]) 423 | [_fileManager removeItemAtPath:downloadPath error:nil]; 424 | 425 | [_fileManager createFileAtPath:downloadPath 426 | contents:nil 427 | attributes:nil]; 428 | 429 | _fileHandle = [NSFileHandle fileHandleForUpdatingAtPath:downloadPath]; 430 | } 431 | 432 | [_fileHandle seekToEndOfFile]; 433 | [_fileHandle writeData:data]; 434 | } 435 | 436 | - (void)connectionDidFinishLoading:(NSURLConnection *)connection { 437 | 438 | [_fileHandle closeFile]; 439 | _fileHandle = nil; 440 | 441 | [self connectionDidFinishLoading]; 442 | 443 | [_URLConnection cancel]; 444 | _URLConnection = nil; 445 | 446 | if (!DCTConnectionControllerCanSetDelegateQueue()) 447 | CFRunLoopStop(CFRunLoopGetCurrent()); 448 | } 449 | 450 | - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { 451 | 452 | [_fileHandle closeFile]; 453 | _fileHandle = nil; 454 | _returnedError = error; 455 | 456 | [self connectionDidFail]; 457 | [_URLConnection cancel]; 458 | _URLConnection = nil; 459 | 460 | if (!DCTConnectionControllerCanSetDelegateQueue()) 461 | CFRunLoopStop(CFRunLoopGetCurrent()); 462 | } 463 | 464 | #pragma mark - Internal 465 | 466 | - (NSString *)fullDescription { 467 | 468 | NSDictionary *headers = self.URLRequest.allHTTPHeaderFields; 469 | __block NSString *headersString = @""; 470 | if ([headers count] > 0) { 471 | headersString = @"\n headers = "; 472 | 473 | [headers enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { 474 | headersString = [headersString stringByAppendingFormat:@"\n %@ = %@", key, obj]; 475 | }]; 476 | } 477 | 478 | NSString *bodyString = @""; 479 | if (self.type == DCTConnectionControllerTypePost) { 480 | NSString *body = [[NSString alloc] initWithData:self.URLRequest.HTTPBody encoding:NSUTF8StringEncoding]; 481 | if ([body length] > 0) 482 | bodyString = [NSString stringWithFormat:@"\n body = \n %@", body]; 483 | } 484 | 485 | return [NSString stringWithFormat:@"\n<%@: %p;\n URL = \"%@\";\n type = %@;%@%@\n status = %@;\n priority = %@\n>", 486 | NSStringFromClass([self class]), 487 | self, 488 | self.URLRequest.URL, 489 | DCTInternalConnectionControllerTypeString[self.type], 490 | headersString, 491 | bodyString, 492 | DCTInternalConnectionControllerStatusString[self.status], 493 | DCTInternalConnectionControllerPriorityString[self.priority]]; 494 | } 495 | 496 | - (NSString *)description { 497 | return [NSString stringWithFormat:@"<%@: %p; URL = \"%@\"; type = %@; status = %@; priority = %@>", 498 | NSStringFromClass([self class]), 499 | self, 500 | self.URLRequest.URL, 501 | DCTInternalConnectionControllerTypeString[self.type], 502 | DCTInternalConnectionControllerStatusString[self.status], 503 | DCTInternalConnectionControllerPriorityString[self.priority]]; 504 | } 505 | 506 | - (BOOL)isEqual:(id)object { 507 | return [self isEqualToConnectionController:object]; 508 | } 509 | 510 | - (NSString *)_domainStringFromURL:(NSURL *)URL { 511 | NSString *urlString = [URL absoluteString]; 512 | urlString = [urlString stringByReplacingOccurrencesOfString:@"http://" withString:@""]; 513 | urlString = [urlString stringByReplacingOccurrencesOfString:@"www." withString:@""]; 514 | urlString = [urlString stringByReplacingOccurrencesOfString:@".com/" withString:@""]; 515 | urlString = [urlString stringByReplacingOccurrencesOfString:@".co.uk/" withString:@""]; 516 | urlString = [urlString stringByReplacingOccurrencesOfString:@".com" withString:@""]; 517 | urlString = [urlString stringByReplacingOccurrencesOfString:@".co.uk" withString:@""]; 518 | return urlString; 519 | 520 | } 521 | 522 | @end 523 | -------------------------------------------------------------------------------- /DCTConnectionController/DCTConnectionControllerDisplay.h: -------------------------------------------------------------------------------- 1 | // 2 | // DCTConnectionControllerDisplay.h 3 | // DCTConnectionController 4 | // 5 | // Created by Daniel Tull on 11.11.2011. 6 | // Copyright (c) 2011 Daniel Tull. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | extern NSString *const DCTConnectionControllerNeedsDisplayNotification; 12 | 13 | @protocol DCTConnectionControllerDisplay 14 | - (void)dismissConnectionControllerDisplay; 15 | @end 16 | 17 | @protocol DCTDisplayableConnectionController 18 | - (BOOL)connectionControllerDisplay:(id)connectionControllerDisplay shouldLoadURLRequest:(NSURLRequest *)urlRequest; 19 | @end 20 | -------------------------------------------------------------------------------- /DCTConnectionController/DCTConnectionControllerDisplay.m: -------------------------------------------------------------------------------- 1 | // 2 | // DCTConnectionControllerDisplay.m 3 | // DCTConnectionController 4 | // 5 | // Created by Daniel Tull on 11.11.2011. 6 | // Copyright (c) 2011 Daniel Tull. All rights reserved. 7 | // 8 | 9 | #import "DCTConnectionControllerDisplay.h" 10 | 11 | NSString *const DCTConnectionControllerNeedsDisplayNotification = @"DCTConnectionControllerNeedsDisplayNotification"; 12 | -------------------------------------------------------------------------------- /DCTConnectionController/DCTConnectionQueue.h: -------------------------------------------------------------------------------- 1 | /* 2 | DCTConnectionQueue.h 3 | DCTConnectionController 4 | 5 | Created by Daniel Tull on 9.6.2010. 6 | 7 | 8 | 9 | Copyright (c) 2010 Daniel Tull. All rights reserved. 10 | 11 | Redistribution and use in source and binary forms, with or without 12 | modification, are permitted provided that the following conditions are met: 13 | 14 | * Redistributions of source code must retain the above copyright notice, this 15 | list of conditions and the following disclaimer. 16 | 17 | * Redistributions in binary form must reproduce the above copyright notice, 18 | this list of conditions and the following disclaimer in the documentation 19 | and/or other materials provided with the distribution. 20 | 21 | * Neither the name of the author nor the names of its contributors may be used 22 | to endorse or promote products derived from this software without specific 23 | prior written permission. 24 | 25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | #import 38 | @class DCTConnectionController; 39 | 40 | extern NSString *const DCTConnectionQueueConnectionCountChangedNotification; 41 | extern NSString *const DCTConnectionQueueActiveConnectionCountChangedNotification; 42 | 43 | extern NSString *const DCTConnectionQueueActiveConnectionCountIncreasedNotification; 44 | extern NSString *const DCTConnectionQueueActiveConnectionCountDecreasedNotification; 45 | 46 | @interface DCTConnectionQueue : NSOperationQueue 47 | 48 | + (DCTConnectionQueue *)defaultConnectionQueue; 49 | - (id)initWithName:(NSString *)name; 50 | 51 | @property (nonatomic, assign) NSUInteger maxConnections; 52 | 53 | @property (nonatomic, readonly) NSArray *connectionControllers; 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /DCTConnectionController/DCTConnectionQueue.m: -------------------------------------------------------------------------------- 1 | /* 2 | DCTConnectionQueue.m 3 | DCTConnectionController 4 | 5 | Created by Daniel Tull on 9.6.2010. 6 | 7 | 8 | 9 | Copyright (c) 2010 Daniel Tull. All rights reserved. 10 | 11 | Redistribution and use in source and binary forms, with or without 12 | modification, are permitted provided that the following conditions are met: 13 | 14 | * Redistributions of source code must retain the above copyright notice, this 15 | list of conditions and the following disclaimer. 16 | 17 | * Redistributions in binary form must reproduce the above copyright notice, 18 | this list of conditions and the following disclaimer in the documentation 19 | and/or other materials provided with the distribution. 20 | 21 | * Neither the name of the author nor the names of its contributors may be used 22 | to endorse or promote products derived from this software without specific 23 | prior written permission. 24 | 25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | #import "DCTConnectionQueue.h" 38 | #import "DCTConnectionController.h" 39 | 40 | NSString *const DCTConnectionQueueConnectionCountChangedNotification = @"DCTConnectionQueueConnectionCountChangedNotification"; 41 | NSString *const DCTConnectionQueueActiveConnectionCountChangedNotification = @"DCTConnectionQueueActiveConnectionCountChangedNotification"; 42 | NSString *const DCTConnectionQueueActiveConnectionCountIncreasedNotification = @"DCTConnectionQueueActiveConnectionCountIncreasedNotification"; 43 | NSString *const DCTConnectionQueueActiveConnectionCountDecreasedNotification = @"DCTConnectionQueueActiveConnectionCountDecreasedNotification"; 44 | 45 | @implementation DCTConnectionQueue { 46 | __strong NSMutableArray *_connectionControllers; 47 | } 48 | 49 | + (DCTConnectionQueue *)defaultConnectionQueue { 50 | static DCTConnectionQueue *sharedInstance = nil; 51 | static dispatch_once_t sharedToken; 52 | dispatch_once(&sharedToken, ^{ 53 | sharedInstance = [self new]; 54 | }); 55 | return sharedInstance; 56 | } 57 | 58 | - (id)initWithName:(NSString *)name { 59 | if (!(self = [super init])) return nil; 60 | _connectionControllers = [NSMutableArray new]; 61 | self.maxConcurrentOperationCount = 5; 62 | [self setName:[NSString stringWithFormat:@"uk.co.danieltull.DCTConnectionQueue.%@", name]]; 63 | return self; 64 | } 65 | 66 | - (id)init { 67 | return [self initWithName:@"defaultConnectionQueue"]; 68 | } 69 | 70 | #pragma mark - DCTConnectionQueue 71 | 72 | - (NSArray *)connectionControllers { 73 | return self.operations; 74 | } 75 | 76 | - (void)_addOperation:(DCTConnectionController *)connectionController { 77 | __unsafe_unretained DCTConnectionQueue *weakSelf = self; 78 | 79 | [connectionController addStatusChangeHandler:^(DCTConnectionControllerStatus status) { 80 | 81 | if (status <= DCTConnectionControllerStatusResponded) return; 82 | 83 | [[NSNotificationCenter defaultCenter] postNotificationName:DCTConnectionQueueActiveConnectionCountDecreasedNotification 84 | object:weakSelf]; 85 | }]; 86 | 87 | [[NSNotificationCenter defaultCenter] postNotificationName:DCTConnectionQueueActiveConnectionCountIncreasedNotification object:self]; 88 | [super addOperation:connectionController]; 89 | } 90 | 91 | - (void)addOperation:(DCTConnectionController *)connectionController { 92 | [connectionController enqueueOnQueue:self]; 93 | } 94 | 95 | - (NSString *)description { 96 | return [NSString stringWithFormat:@"<%@: %p; name = \"%@\">", 97 | NSStringFromClass([self class]), 98 | self, 99 | self.name]; 100 | } 101 | 102 | @end 103 | -------------------------------------------------------------------------------- /DCTConnectionController/DCTRESTConnectionController.h: -------------------------------------------------------------------------------- 1 | /* 2 | DCTRESTController.h 3 | DCTConnectionController 4 | 5 | Created by Daniel Tull on 8.8.2010. 6 | 7 | 8 | Copyright (c) 2010 Daniel Tull. All rights reserved. 9 | 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | 13 | * Redistributions of source code must retain the above copyright notice, this 14 | list of conditions and the following disclaimer. 15 | 16 | * Redistributions in binary form must reproduce the above copyright notice, 17 | this list of conditions and the following disclaimer in the documentation 18 | and/or other materials provided with the distribution. 19 | 20 | * Neither the name of the author nor the names of its contributors may be used 21 | to endorse or promote products derived from this software without specific 22 | prior written permission. 23 | 24 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 28 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 32 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | #import "DCTConnectionController.h" 37 | 38 | /** The DCTRESTController subclass of DCTConnectionController allows easier building of URL requests in general. 39 | 40 | The loadURLRequest method in this subclass asks for queryProperties , bodyProperties and headerProperties to build up 41 | a complete URL request to the location given by baseURLString . When subclassing , you should 42 | implement these methods to allow DCTRESTController to build the request, rather than implementing loadURLRequest as you 43 | would with other connection controllers. 44 | */ 45 | @interface DCTRESTConnectionController : DCTConnectionController 46 | 47 | /// @name Methods to subclass 48 | 49 | /** Returns the query properties implemented in each subclass. 50 | 51 | This should be overridden by subclasses to give properties to be automatically used in the query string. 52 | */ 53 | + (NSArray *)queryProperties; 54 | 55 | /** Returns the body properties implemented in each subclass. 56 | 57 | This should be overridden by subclasses to give properties to be automatically used in a body form. 58 | */ 59 | + (NSArray *)bodyFormProperties; 60 | 61 | - (NSData *)bodyData; 62 | 63 | /** Returns the header properties implemented in each subclass. 64 | 65 | This should be overridden by subclasses to give properties to be automatically used in the header. 66 | */ 67 | + (NSArray *)headerProperties; 68 | 69 | /** Returns the base URL as a string. 70 | 71 | This should be overridden by subclasses to give the base URL to the core 72 | */ 73 | - (NSString *)baseURLString; 74 | 75 | /** Allows the receiver to return a different value for the given connection key. 76 | 77 | There are two scenarios where you might want to use this method: 78 | 79 | The first is if you want to define a connection (query, body or header) property, that 80 | is the same as an existing property on DCTConnectionController. For example, if the web service 81 | requires a "type" query parameter, then you can use this method to override the value used. 82 | Return @"type" as one of the keys in queryProperties, and check for the @"type" as the key. 83 | 84 | The second is if you want to use a different value type than that used for the type of the 85 | object to be used as in the connection property object. For example you may have an enum to 86 | define the proprety, but the web service requires a string. 87 | 88 | In general, this should return a string. 89 | 90 | By default this method returns the result of valueForKey:, thus by not implementing this method, 91 | this class acts the same as pre version 2.0.2. 92 | 93 | @param key The connection property key. 94 | @return The value for the given key. 95 | 96 | @see queryProperties 97 | @see bodyProperties 98 | @see headerProperties 99 | */ 100 | - (id)valueForConnectionKey:(id)key; 101 | 102 | @end 103 | -------------------------------------------------------------------------------- /DCTConnectionController/DCTRESTConnectionController.m: -------------------------------------------------------------------------------- 1 | /* 2 | DCTRESTController.m 3 | DCTConnectionController 4 | 5 | Created by Daniel Tull on 8.8.2010. 6 | 7 | 8 | 9 | Copyright (c) 2010 Daniel Tull. All rights reserved. 10 | 11 | Redistribution and use in source and binary forms, with or without 12 | modification, are permitted provided that the following conditions are met: 13 | 14 | * Redistributions of source code must retain the above copyright notice, this 15 | list of conditions and the following disclaimer. 16 | 17 | * Redistributions in binary form must reproduce the above copyright notice, 18 | this list of conditions and the following disclaimer in the documentation 19 | and/or other materials provided with the distribution. 20 | 21 | * Neither the name of the author nor the names of its contributors may be used 22 | to endorse or promote products derived from this software without specific 23 | prior written permission. 24 | 25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | #import "DCTRESTConnectionController.h" 38 | #import 39 | #import "NSString+DCTURLEncoding.h" 40 | 41 | typedef id (^DCTInternalRESTControllerKeyValueStringConvertor) (id, id); 42 | 43 | @interface DCTRESTConnectionController () 44 | - (NSArray *)dctInternal_keyValueStringsForKeys:(NSSet *)keys stringConvertor:(DCTInternalRESTControllerKeyValueStringConvertor)convertor; 45 | @end 46 | 47 | @implementation DCTRESTConnectionController 48 | 49 | + (NSArray *)headerProperties { 50 | return nil; 51 | } 52 | 53 | + (NSArray *)bodyFormProperties { 54 | return nil; 55 | } 56 | 57 | + (NSArray *)queryProperties { 58 | return nil; 59 | } 60 | 61 | - (NSString *)baseURLString { 62 | return @""; 63 | } 64 | 65 | - (id)valueForConnectionKey:(id)key { 66 | return [self valueForKey:key]; 67 | } 68 | 69 | - (void)loadURLRequest { 70 | 71 | [super loadURLRequest]; 72 | 73 | NSMutableURLRequest *request = [self.URLRequest mutableCopy]; 74 | NSMutableSet *queries = [NSMutableSet set]; 75 | NSMutableSet *headers = [NSMutableSet set]; 76 | 77 | Class class = [self class]; 78 | while ([class isSubclassOfClass:[DCTRESTConnectionController class]] && ![[DCTRESTConnectionController class] isSubclassOfClass:class]) { 79 | 80 | NSArray *classQueries = [class queryProperties]; 81 | if (classQueries) [queries addObjectsFromArray:classQueries]; 82 | 83 | NSArray *classHeaders = [class headerProperties]; 84 | if (classHeaders) [headers addObjectsFromArray:classHeaders]; 85 | 86 | class = class_getSuperclass(class); 87 | } 88 | 89 | DCTInternalRESTControllerKeyValueStringConvertor convertor = ^(id key, id value) { 90 | return [NSString stringWithFormat:@"%@=%@", key, [value dct_urlEncodedString]]; 91 | }; 92 | 93 | if ([queries count] == 0) { 94 | [request setURL:[NSURL URLWithString:[self baseURLString]]]; 95 | } else { 96 | NSArray *queryKeyValues = [self dctInternal_keyValueStringsForKeys:queries stringConvertor:convertor]; 97 | NSString *queryString = [queryKeyValues componentsJoinedByString:@"&"]; 98 | [request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?%@", [self baseURLString], queryString]]]; 99 | } 100 | 101 | [request setHTTPBody:[self bodyData]]; 102 | 103 | [self dctInternal_keyValueStringsForKeys:headers stringConvertor:^(id key, id value){ 104 | [request addValue:value forHTTPHeaderField:key]; 105 | return [NSString stringWithFormat:@"%@: %@", key, value]; 106 | }]; 107 | 108 | self.URLRequest = request; 109 | } 110 | 111 | - (NSData *)bodyData { 112 | NSMutableSet *bodies = [NSMutableSet set]; 113 | 114 | Class class = [self class]; 115 | while ([class isSubclassOfClass:[DCTRESTConnectionController class]] && ![[DCTRESTConnectionController class] isSubclassOfClass:class]) { 116 | 117 | NSArray *classBodies = [class bodyFormProperties]; 118 | if (classBodies) [bodies addObjectsFromArray:classBodies]; 119 | 120 | class = class_getSuperclass(class); 121 | } 122 | 123 | NSArray *bodyKeyValues = [self dctInternal_keyValueStringsForKeys:bodies stringConvertor:^(id key, id value) { 124 | return [NSString stringWithFormat:@"%@=%@", key, [value dct_urlEncodedString]]; 125 | }]; 126 | NSString *bodyString = [bodyKeyValues componentsJoinedByString:@"&"]; 127 | return [bodyString dataUsingEncoding:NSUTF8StringEncoding]; 128 | } 129 | 130 | - (NSArray *)dctInternal_keyValueStringsForKeys:(NSSet *)keys stringConvertor:(DCTInternalRESTControllerKeyValueStringConvertor)convertor { 131 | 132 | NSMutableArray *strings = [NSMutableArray arrayWithCapacity:[keys count]]; 133 | 134 | for (NSString *key in keys) { 135 | 136 | id value = [self valueForConnectionKey:key]; 137 | 138 | if (value && ![value isKindOfClass:[NSString class]]) 139 | value = [value description]; 140 | 141 | if ([value length] > 0) 142 | [strings addObject:convertor(key, value)]; 143 | } 144 | return [NSArray arrayWithArray:strings]; 145 | } 146 | 147 | 148 | 149 | @end 150 | -------------------------------------------------------------------------------- /DCTConnectionController/NSString+DCTURLEncoding.h: -------------------------------------------------------------------------------- 1 | /* 2 | NSString+DCTURLEncoding.h 3 | DCTConnectionController 4 | 5 | Created by Daniel Tull on 4.7.2010. 6 | 7 | 8 | 9 | Copyright (c) 2010 Daniel Tull. All rights reserved. 10 | 11 | Redistribution and use in source and binary forms, with or without 12 | modification, are permitted provided that the following conditions are met: 13 | 14 | * Redistributions of source code must retain the above copyright notice, this 15 | list of conditions and the following disclaimer. 16 | 17 | * Redistributions in binary form must reproduce the above copyright notice, 18 | this list of conditions and the following disclaimer in the documentation 19 | and/or other materials provided with the distribution. 20 | 21 | * Neither the name of the author nor the names of its contributors may be used 22 | to endorse or promote products derived from this software without specific 23 | prior written permission. 24 | 25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | #import 38 | 39 | 40 | @interface NSString (DCTURLEncoding) 41 | 42 | /** Get a URL encoded string. 43 | */ 44 | - (NSString *)dct_urlEncodedString; 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /DCTConnectionController/NSString+DCTURLEncoding.m: -------------------------------------------------------------------------------- 1 | /* 2 | NSString+DCTURLEncoding.m 3 | DCTConnectionController 4 | 5 | Created by Daniel Tull on 4.7.2010. 6 | 7 | 8 | 9 | Copyright (c) 2010 Daniel Tull. All rights reserved. 10 | 11 | Redistribution and use in source and binary forms, with or without 12 | modification, are permitted provided that the following conditions are met: 13 | 14 | * Redistributions of source code must retain the above copyright notice, this 15 | list of conditions and the following disclaimer. 16 | 17 | * Redistributions in binary form must reproduce the above copyright notice, 18 | this list of conditions and the following disclaimer in the documentation 19 | and/or other materials provided with the distribution. 20 | 21 | * Neither the name of the author nor the names of its contributors may be used 22 | to endorse or promote products derived from this software without specific 23 | prior written permission. 24 | 25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 29 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 33 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | #import "NSString+DCTURLEncoding.h" 38 | 39 | 40 | @implementation NSString (DCTURLEncoding) 41 | - (NSString *)dct_urlEncodedString { 42 | 43 | return (__bridge_transfer NSString *) CFURLCreateStringByAddingPercentEscapes(NULL, 44 | (CFStringRef)objc_unretainedPointer(self), 45 | NULL, 46 | (CFStringRef)@"!*'();:@&=+$,/?%#[]", 47 | kCFStringEncodingUTF8); 48 | } 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /DCTConnectionController/_DCTConnectionQueue.h: -------------------------------------------------------------------------------- 1 | // 2 | // _DCTConnectionQueue.h 3 | // DCTConnectionController 4 | // 5 | // Created by Daniel Tull on 16/07/2012. 6 | // Copyright (c) 2012 Daniel Tull. All rights reserved. 7 | // 8 | 9 | #import "DCTConnectionQueue.h" 10 | 11 | @interface DCTConnectionQueue (_DCTConnectionQueue) 12 | - (void)_addOperation:(DCTConnectionController *)connectionController; 13 | @end 14 | -------------------------------------------------------------------------------- /DCTConnectionControllerTests/DCTConnectionControllerTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | uk.co.danieltull.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /DCTConnectionControllerTests/DCTConnectionControllerTests.h: -------------------------------------------------------------------------------- 1 | // 2 | // DCTConnectionControllerTests.h 3 | // DCTConnectionControllerTests 4 | // 5 | // Created by Daniel Tull on 14.06.2012. 6 | // Copyright (c) 2012 Daniel Tull. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DCTConnectionControllerTests : SenTestCase 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /DCTConnectionControllerTests/DCTConnectionControllerTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // DCTConnectionControllerTests.m 3 | // DCTConnectionControllerTests 4 | // 5 | // Created by Daniel Tull on 14.06.2012. 6 | // Copyright (c) 2012 Daniel Tull. All rights reserved. 7 | // 8 | 9 | #import "DCTConnectionControllerTests.h" 10 | 11 | @implementation DCTConnectionControllerTests 12 | 13 | - (void)setUp 14 | { 15 | [super setUp]; 16 | 17 | // Set-up code here. 18 | } 19 | 20 | - (void)tearDown 21 | { 22 | // Tear-down code here. 23 | 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample 28 | { 29 | STFail(@"Unit tests are not implemented yet in DCTConnectionControllerTests"); 30 | } 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /DCTConnectionControllerTests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Mac Demo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // Mac Demo 4 | // 5 | // Created by Daniel Tull on 06/07/2012. 6 | // Copyright (c) 2012 Daniel Tull. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : NSObject 12 | 13 | @property (assign) IBOutlet NSWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Mac Demo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // Mac Demo 4 | // 5 | // Created by Daniel Tull on 06/07/2012. 6 | // Copyright (c) 2012 Daniel Tull. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import 11 | 12 | NSString * const ViewControllerStatusString[] = { 13 | @"NotStarted", 14 | @"Queued", 15 | @"Started", 16 | @"Responded", 17 | @"Completed", 18 | @"Failed", 19 | @"Cancelled" 20 | }; 21 | 22 | @implementation AppDelegate 23 | 24 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { 25 | 26 | NSArray *urls = @[@"http://www.tesco.com/", 27 | @"http://www.nike.com/", 28 | @"http://www.coca-cola.com/", 29 | @"http://www.no.danieltull.co.uk/", 30 | @"http://www.oakley.com/", 31 | @"http://www.sky.com/", 32 | @"http://www.yahoo.com/", 33 | @"http://www.microsoft.com/", 34 | @"http://www.play.com/"]; 35 | 36 | for (NSString *s in urls) { 37 | NSURL *URL = [NSURL URLWithString:s]; 38 | NSURLRequest *URLRequest = [[NSURLRequest alloc] initWithURL:URL]; 39 | DCTConnectionController *connectionController = [[DCTConnectionController alloc] initWithURLRequest:URLRequest]; 40 | NSString *domain = [self _domainStringFromURL:connectionController.URLRequest.URL]; 41 | 42 | [connectionController addStatusChangeHandler:^(DCTConnectionControllerStatus status) { 43 | NSLog(@"%@:%@ %@ %@", self, NSStringFromSelector(_cmd), domain, ViewControllerStatusString[status]); 44 | }]; 45 | [connectionController enqueue]; 46 | } 47 | } 48 | 49 | - (NSString *)_domainStringFromURL:(NSURL *)URL { 50 | NSString *urlString = [URL absoluteString]; 51 | urlString = [urlString stringByReplacingOccurrencesOfString:@"http://" withString:@""]; 52 | urlString = [urlString stringByReplacingOccurrencesOfString:@"www." withString:@""]; 53 | urlString = [urlString stringByReplacingOccurrencesOfString:@".com/" withString:@""]; 54 | urlString = [urlString stringByReplacingOccurrencesOfString:@".co.uk/" withString:@""]; 55 | urlString = [urlString stringByReplacingOccurrencesOfString:@".com" withString:@""]; 56 | urlString = [urlString stringByReplacingOccurrencesOfString:@".co.uk" withString:@""]; 57 | return urlString; 58 | 59 | } 60 | 61 | @end 62 | -------------------------------------------------------------------------------- /Mac Demo/Mac Demo-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | uk.co.danieltull.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSApplicationCategoryType 26 | public.app-category.developer-tools 27 | LSMinimumSystemVersion 28 | ${MACOSX_DEPLOYMENT_TARGET} 29 | NSHumanReadableCopyright 30 | Copyright © 2012 Daniel Tull. All rights reserved. 31 | NSMainNibFile 32 | MainMenu 33 | NSPrincipalClass 34 | NSApplication 35 | 36 | 37 | -------------------------------------------------------------------------------- /Mac Demo/Mac Demo-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'Mac Demo' target in the 'Mac Demo' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /Mac Demo/en.lproj/Credits.rtf: -------------------------------------------------------------------------------- 1 | {\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;} 2 | {\colortbl;\red255\green255\blue255;} 3 | \paperw9840\paperh8400 4 | \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural 5 | 6 | \f0\b\fs24 \cf0 Engineering: 7 | \b0 \ 8 | Some people\ 9 | \ 10 | 11 | \b Human Interface Design: 12 | \b0 \ 13 | Some other people\ 14 | \ 15 | 16 | \b Testing: 17 | \b0 \ 18 | Hopefully not nobody\ 19 | \ 20 | 21 | \b Documentation: 22 | \b0 \ 23 | Whoever\ 24 | \ 25 | 26 | \b With special thanks to: 27 | \b0 \ 28 | Mom\ 29 | } 30 | -------------------------------------------------------------------------------- /Mac Demo/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Mac Demo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // Mac Demo 4 | // 5 | // Created by Daniel Tull on 06/07/2012. 6 | // Copyright (c) 2012 Daniel Tull. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | return NSApplicationMain(argc, (const char **)argv); 14 | } 15 | -------------------------------------------------------------------------------- /Readme.textile: -------------------------------------------------------------------------------- 1 | h1. DCTConnectionController 2 | 3 | @DCTConnectionController@ and the associated classes are my way to handle URL connections, specifically those made to RESTful services. 4 | 5 | Connection controller subclasses should manage the connection and handle callbacks, most likely translating them into model objects that make sense to the rest of the application. In this way connection controllers can be called by other objects without needing any knowledge of how the connection is performed or the web API calls that are needed. 6 | 7 | @DCTConnectionQueue@ is used to queue up connection controllers, and managed the order in which they are run. It also allows the limiting of the amount of connections occurring. 8 | 9 | @DCTConnectionGroup@ is class to monitor a group of connection controllers and be notified when they have all ended; Be it through successfully finishing, failure or cancellation. 10 | 11 | There is a category on @DCTConnectionQueue@ to allow access to a global queue, and a convenience method on DCTConnectionController to easily queue connections on this global queue. You are, however, not bound to using this global queue and can use multiple queues as you wish. 12 | 13 | h2. DCTConnectionController 2.1 Notes 14 | 15 | * Adds @DCTConnectionGroup@ class to monitor a group of connections controllers. 16 | * Adds @-[DCTConnectionQueue addConnectionGroup:]@ to queue up a connection group. 17 | * Adds a notification that the connection controller needs display (through a webview) to allow a view layer to handle things like OAuth connections. 18 | * Adds @-[DCTConnectionController queue]@ 19 | * @-[DCTConnectionController returnedObject]@ is now of type @id@. 20 | * Moves the @delegate@ property of @DCTConnectionController@ to a category, as well as the delegate handling. 21 | * Makes the @downloadPath@ property setable, moving it to a category. Setting this will copy the downloaded data to the path provided. *Warning:* You can no long override this in a subclass to achieve this, it must be set. 22 | * Fixes a bug where the same connection controller would get queued up more than once if @-[DCTConnectionController connect]@, @-[DCTConnectionController connectOnQueue:]@ or @-[DCTConnectionQueue addConnectionController:]@ was called more than once. 23 | * Fixes a bug where called @-[DCTConnectionQueue addConnectionController:]@ would not check for duplicates on the queue. 24 | * Deprecates @-[DCTConnectionControllerDelegate connectionController:didReceiveObject:]@, use @-[DCTConnectionControllerDelegate connectionControllerDidFinish:]@ instead. The original delegate method is still called in version 2.1 though. 25 | 26 | h2. DCTConnectionController 2.0 Notes 27 | 28 | * The API for the new version of @DCTConnectionController@ has been revised and care should be handled when upgrading to the new version. 29 | * The functionality of @DCTURLConnectionController@ and @DCTRequestConnectionController@ have been moved into @DCTConnectionController@ itself. 30 | * The multitasking additions to @DCTConnectionQueue@ have been moved to their "own repository":https://github.com/danielctull/DCTConnectionController-UIKit to be further built upon. 31 | * Handling of the iOS activity indicator has been moved to "DCTNetworkActivityIndicatorController":https://github.com/danielctull/DCTNetworkActivityIndicatorController. To get the indicator functionality of DCTConnectionController 1.0, add @DCTNetworkActivityIndicatorController@ and it will automatically register for notifications sent by @DCTConnectionQueue@(s). 32 | 33 | h2. UIKit Additions 34 | 35 | The UIKit category on @DCTConnectionQueue@ allows it to handle iOS multitasking and the application-wide network activity indicator. As of *DCTConnectionController 2.0*, this category is now in its "own repository":https://github.com/danielctull/DCTConnectionController-UIKit. 36 | 37 | h2. Documentation 38 | 39 | There exists some pretty extensive "DCTConnectionController documentation":http://danieltull.co.uk/DCTConnectionController/Documentation/ generated with "appledoc":https://github.com/tomaz/appledoc. 40 | 41 | h2. Services 42 | 43 | Currently, the following services have been written using connection controllers: 44 | 45 | * "DCTInstapaper":https://github.com/danielctull/DCTInstapaper 46 | * "DCTGravatar":https://github.com/danielctull/DCTGravatar 47 | 48 | h2. Branch Structure 49 | 50 | There is a new branch structure for DCTConnectionController 2.0, *master* and *demo*. Unlike previous versions, *master* is now the branch to use as a submodule. 51 | 52 | h3. master 53 | 54 | The master branch contains the code and should be used if you want to add these extensions as a git submodule in other projects. It will only contain the class files themselves without the Xcode project or example classes. This is preferable as it will keep your directories clean of any code which is unnecessary to your working project. 55 | 56 | To add this project as a submodule you should run the following from inside your project's git repository: 57 | 58 | bc. git submodule add git://github.com/danielctull/DCTConnectionController.git 59 | 60 | To keep up to date with the latest changes `cd` into the directory that contains this submodule and pull the newest changes as usual: 61 | 62 | bc. git pull origin 63 | 64 | h3. demo 65 | 66 | This contains an Xcode project that demonstrates the code and is the branch to use to see how to use the code. The demo branch contains a submodule reference to the master branch to bring in the library classes. 67 | 68 | To clone the demo branch, while also pulling in any necessary submodules run the following command: 69 | 70 | bc. git clone -b demo --recursive git://github.com/danielctull/DCTConnectionController.git 71 | 72 | When changing to the demo branch you will need to run through the following set of commands: 73 | 74 | bc. git checkout demo 75 | git submodule init 76 | git submodule update 77 | 78 | After these you will see the example project and the library code will be in a sub-directory. 79 | 80 | h3. Artefacts 81 | 82 | Sometimes, there may be artefacts left over when switching from demo to master. These are files that are ignored by git and are easily cleaned up by running 83 | 84 | bc. git clean -dxf 85 | 86 | h2. Examples 87 | 88 | Examples of some of these features can be found in the iPhone app delegate. 89 | 90 | h2. License 91 | 92 | Copyright (C) 2010 Daniel Tull. All rights reserved. 93 | 94 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 95 | 96 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 97 | 98 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 99 | 100 | * Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 101 | 102 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /iPhone Demo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // DCTConnectionControllerDemo 4 | // 5 | // Created by Daniel Tull on 25.06.2012. 6 | // Copyright (c) 2012 Daniel Tull. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /iPhone Demo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // DCTConnectionControllerDemo 4 | // 5 | // Created by Daniel Tull on 25.06.2012. 6 | // Copyright (c) 2012 Daniel Tull. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "ViewController.h" 11 | 12 | @implementation AppDelegate 13 | 14 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 15 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 16 | self.window.backgroundColor = [UIColor whiteColor]; 17 | 18 | ViewController *vc = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil]; 19 | self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:vc]; 20 | [self.window makeKeyAndVisible]; 21 | 22 | return YES; 23 | } 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /iPhone Demo/DCTConnectionControllerDemo-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | DCTCC Demo 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | uk.co.danieltull.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /iPhone Demo/DCTConnectionControllerDemo-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'DCTConnectionControllerDemo' target in the 'DCTConnectionControllerDemo' project 3 | // 4 | 5 | #import 6 | 7 | #ifndef __IPHONE_3_0 8 | #warning "This project uses features only available in iOS SDK 3.0 and later." 9 | #endif 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #endif 15 | -------------------------------------------------------------------------------- /iPhone Demo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // DCTConnectionKitExampleViewController.h 3 | // DCTConnectionKit 4 | // 5 | // Created by Daniel Tull on 14.12.2009. 6 | // Copyright 2009 Daniel Tull. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | @property (nonatomic, weak) IBOutlet UITextView *textView; 13 | @property (nonatomic, weak) IBOutlet UIToolbar *toolbar; 14 | @property (nonatomic, weak) IBOutlet UILabel *connectionsAmountLabel; 15 | @property (nonatomic, weak) IBOutlet UILabel *queuedAmountLabel; 16 | @property (nonatomic, weak) IBOutlet UILabel *activeAmountLabel; 17 | @end 18 | -------------------------------------------------------------------------------- /iPhone Demo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // DCTConnectionKitExampleViewController.m 3 | // DCTConnectionKit 4 | // 5 | // Created by Daniel Tull on 14.12.2009. 6 | // Copyright 2009 Daniel Tull. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "ViewController.h" 12 | 13 | NSString * const ViewControllerStatusString[] = { 14 | @"NotStarted", 15 | @"Queued", 16 | @"Started", 17 | @"Responded", 18 | @"Finished", 19 | @"Failed", 20 | @"Cancelled" 21 | }; 22 | 23 | @implementation ViewController 24 | 25 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { 26 | if (!(self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) return nil; 27 | self.title = @"DCTConnectionController"; 28 | return self; 29 | } 30 | 31 | - (void)viewDidLoad { 32 | [super viewDidLoad]; 33 | 34 | NSArray *urls = @[@"http://www.tesco.com/", 35 | @"http://www.nike.com/", 36 | @"http://www.coca-cola.com/", 37 | @"http://www.no.danieltull.co.uk/", 38 | @"http://www.oakley.com/", 39 | @"http://www.sky.com/", 40 | @"http://www.yahoo.com/", 41 | @"http://www.microsoft.com/", 42 | @"http://www.play.com/"]; 43 | 44 | for (NSString *s in urls) { 45 | NSURL *URL = [NSURL URLWithString:s]; 46 | NSURLRequest *URLRequest = [[NSURLRequest alloc] initWithURL:URL]; 47 | DCTConnectionController *connectionController = [[DCTConnectionController alloc] initWithURLRequest:URLRequest]; 48 | NSString *domain = [self _domainStringFromURL:connectionController.URLRequest.URL]; 49 | 50 | [connectionController addStatusChangeHandler:^(DCTConnectionControllerStatus status) { 51 | [[NSOperationQueue mainQueue] addOperationWithBlock:^{ 52 | 53 | NSArray *connectionControllers = [[DCTConnectionQueue defaultConnectionQueue] connectionControllers]; 54 | 55 | NSArray *active = [connectionControllers filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(DCTConnectionController *cc, NSDictionary *bindings) { 56 | return (cc.status > DCTConnectionControllerStatusQueued); 57 | }]]; 58 | 59 | NSArray *queued = [connectionControllers filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(DCTConnectionController *cc, NSDictionary *bindings) { 60 | return (cc.status == DCTConnectionControllerStatusQueued); 61 | }]]; 62 | 63 | self.activeAmountLabel.text = [NSString stringWithFormat:@"%i", [active count]]; 64 | self.connectionsAmountLabel.text = [NSString stringWithFormat:@"%i", [connectionControllers count]]; 65 | self.queuedAmountLabel.text = [NSString stringWithFormat:@"%i", [queued count]]; 66 | 67 | [self log:@"%@ %@", domain, ViewControllerStatusString[status]]; 68 | }]; 69 | }]; 70 | [connectionController enqueue]; 71 | } 72 | 73 | /* 74 | DCTConnectionController *engadget = [[DCTConnectionController alloc] init]; 75 | engadget.URL = [NSURL URLWithString:@"http://www.engadget.com/"]; 76 | [engadget connect]; 77 | 78 | // Make a duplicate, won't get queued. 79 | DCTConnectionController *engadget2 = [[DCTConnectionController alloc] init]; 80 | engadget2.URL = [NSURL URLWithString:@"http://www.engadget.com/"]; 81 | engadget.priority = DCTConnectionControllerPriorityHigh; 82 | [engadget2 connect]; 83 | 84 | DCTConnectionController *ebay = [[DCTConnectionController alloc] init]; 85 | ebay.URL = [NSURL URLWithString:@"http://www.ebay.com/"]; 86 | ebay.priority = DCTConnectionControllerPriorityLow; 87 | [ebay connect]; 88 | 89 | DCTConnectionController *google = [[DCTConnectionController alloc] init]; 90 | google.URL = [NSURL URLWithString:@"http://www.google.com/"]; 91 | google.priority = DCTConnectionControllerPriorityLow; 92 | [google addDependency:ebay]; 93 | [google connect]; 94 | 95 | DCTConnectionController *apple = [[DCTConnectionController alloc] init]; 96 | apple.URL = [NSURL URLWithString:@"http://www.apple.com/"]; 97 | apple.priority = DCTConnectionControllerPriorityLow; 98 | [apple addDependency:google]; 99 | [apple connect]; 100 | 101 | DCTConnectionController *bbc = [[DCTConnectionController alloc] init]; 102 | bbc.URL = [NSURL URLWithString:@"http://www.bbc.co.uk/"]; 103 | bbc.priority = DCTConnectionControllerPriorityHigh; 104 | [bbc addDependency:apple]; 105 | [bbc connect]; */ 106 | } 107 | 108 | - (void)log:(NSString *)formatString, ... { 109 | 110 | BOOL shouldScroll = (self.textView.contentOffset.y + self.textView.bounds.size.height >= self.textView.contentSize.height); 111 | 112 | va_list args; 113 | va_start(args, formatString); 114 | NSString *string = [[NSString alloc] initWithFormat:formatString arguments:args]; 115 | va_end(args); 116 | 117 | NSDateFormatter *df = [[NSDateFormatter alloc] init]; 118 | [df setDateFormat:@"HH:mm:ss.SSS"]; 119 | NSString *dateString = [df stringFromDate:[NSDate date]]; 120 | 121 | NSString *newLine = @""; 122 | if ([self.textView.text length] > 0) { 123 | newLine = @"\n"; 124 | } 125 | 126 | self.textView.text = [self.textView.text stringByAppendingFormat:@"%@%@ %@", newLine, dateString, string]; 127 | 128 | if (shouldScroll) 129 | [self.textView scrollRectToVisible:CGRectMake(0.0, self.textView.contentSize.height - self.textView.bounds.size.height, self.textView.bounds.size.width, self.textView.bounds.size.height) animated:NO]; 130 | } 131 | 132 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { 133 | return YES; 134 | } 135 | 136 | - (NSString *)_domainStringFromURL:(NSURL *)URL { 137 | NSString *urlString = [URL absoluteString]; 138 | urlString = [urlString stringByReplacingOccurrencesOfString:@"http://" withString:@""]; 139 | urlString = [urlString stringByReplacingOccurrencesOfString:@"www." withString:@""]; 140 | urlString = [urlString stringByReplacingOccurrencesOfString:@".com/" withString:@""]; 141 | urlString = [urlString stringByReplacingOccurrencesOfString:@".co.uk/" withString:@""]; 142 | urlString = [urlString stringByReplacingOccurrencesOfString:@".com" withString:@""]; 143 | urlString = [urlString stringByReplacingOccurrencesOfString:@".co.uk" withString:@""]; 144 | return urlString; 145 | 146 | } 147 | 148 | @end 149 | -------------------------------------------------------------------------------- /iPhone Demo/ViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1536 5 | 11E53 6 | 2541 7 | 1138.47 8 | 569.00 9 | 10 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 11 | 1875 12 | 13 | 14 | IBProxyObject 15 | IBUIBarButtonItem 16 | IBUILabel 17 | IBUITextView 18 | IBUIToolbar 19 | IBUIView 20 | 21 | 22 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 23 | 24 | 25 | PluginDependencyRecalculationVersion 26 | 27 | 28 | 29 | 30 | IBFilesOwner 31 | IBCocoaTouchFramework 32 | 33 | 34 | IBFirstResponder 35 | IBCocoaTouchFramework 36 | 37 | 38 | 39 | 292 40 | 41 | 42 | 43 | 274 44 | {320, 416} 45 | 46 | 47 | 48 | NO 49 | YES 50 | YES 51 | IBCocoaTouchFramework 52 | NO 53 | NO 54 | NO 55 | NO 56 | NO 57 | 58 | IBCocoaTouchFramework 59 | 60 | 61 | 62 | CourierNewPSMT 63 | Courier New 64 | 0 65 | 14 66 | 67 | 68 | CourierNewPSMT 69 | 14 70 | 16 71 | 72 | 73 | 74 | 75 | 266 76 | 77 | 78 | 79 | 274 80 | 81 | 82 | 83 | 274 84 | {77, 15} 85 | 86 | 87 | 88 | NO 89 | YES 90 | NO 91 | IBCocoaTouchFramework 92 | 93 | 94 | 1 95 | MCAwIDAgMC41AA 96 | 97 | 1 98 | 10 99 | Connections: 100 | 101 | 3 102 | MQA 103 | 104 | 105 | Helvetica-Bold 106 | Helvetica 107 | 2 108 | 12 109 | 110 | 111 | Helvetica-Bold 112 | 12 113 | 16 114 | 115 | 2 116 | 117 | 118 | 119 | 274 120 | {{85, 0}, {21, 15}} 121 | 122 | 123 | 124 | NO 125 | YES 126 | NO 127 | IBCocoaTouchFramework 128 | 129 | 130 | 1 131 | MCAwIDAgMC41AA 132 | 133 | 1 134 | 10 135 | 999 136 | 137 | 138 | 139 | 2 140 | 141 | 142 | {{12, 14}, {106, 16}} 143 | 144 | 145 | 146 | 147 | 3 148 | MSAwAA 149 | 150 | IBCocoaTouchFramework 151 | 152 | 153 | 154 | 274 155 | 156 | 157 | 158 | 274 159 | {49, 16} 160 | 161 | 162 | 163 | NO 164 | YES 165 | NO 166 | IBCocoaTouchFramework 167 | 168 | 169 | 1 170 | MCAwIDAgMC41AA 171 | 172 | 1 173 | 10 174 | Queued: 175 | 176 | 177 | 178 | 2 179 | 180 | 181 | 182 | 274 183 | {{57, 0}, {21, 15}} 184 | 185 | 186 | 187 | NO 188 | YES 189 | NO 190 | IBCocoaTouchFramework 191 | 192 | 193 | 1 194 | MCAwIDAgMC41AA 195 | 196 | 1 197 | 10 198 | 999 199 | 200 | 201 | 202 | 2 203 | 204 | 205 | {{138, 14}, {78, 16}} 206 | 207 | 208 | 209 | 210 | 3 211 | MSAwAA 212 | 213 | IBCocoaTouchFramework 214 | 215 | 216 | 217 | 274 218 | 219 | 220 | 221 | 274 222 | {41, 16} 223 | 224 | 225 | 226 | NO 227 | YES 228 | NO 229 | IBCocoaTouchFramework 230 | 231 | 232 | 1 233 | MCAwIDAgMC41AA 234 | 235 | 1 236 | 10 237 | Active: 238 | 239 | 240 | 241 | 2 242 | 243 | 244 | 245 | 274 246 | {{49, 1}, {21, 15}} 247 | 248 | 249 | NO 250 | YES 251 | NO 252 | IBCocoaTouchFramework 253 | 254 | 255 | 1 256 | MCAwIDAgMC41AA 257 | 258 | 1 259 | 10 260 | 999 261 | 262 | 263 | 264 | 2 265 | 266 | 267 | {{236, 14}, {70, 16}} 268 | 269 | 270 | 271 | 272 | 3 273 | MSAwAA 274 | 275 | IBCocoaTouchFramework 276 | 277 | 278 | {{0, 416}, {320, 44}} 279 | 280 | 281 | 282 | NO 283 | NO 284 | IBCocoaTouchFramework 285 | 286 | 287 | IBCocoaTouchFramework 288 | 289 | 290 | 291 | 292 | IBCocoaTouchFramework 293 | 10 294 | 295 | 6 296 | 297 | 298 | IBCocoaTouchFramework 299 | 300 | 301 | 302 | 303 | IBCocoaTouchFramework 304 | 10 305 | 306 | 6 307 | 308 | 309 | IBCocoaTouchFramework 310 | 311 | 312 | 313 | 314 | 315 | 316 | {320, 460} 317 | 318 | 319 | 320 | _NS:196 321 | 322 | 3 323 | MQA 324 | 325 | 2 326 | 327 | 328 | IBCocoaTouchFramework 329 | 330 | 331 | 332 | 333 | 334 | 335 | textView 336 | 337 | 338 | 339 | 5 340 | 341 | 342 | 343 | view 344 | 345 | 346 | 347 | 69 348 | 349 | 350 | 351 | toolbar 352 | 353 | 354 | 355 | 70 356 | 357 | 358 | 359 | activeAmountLabel 360 | 361 | 362 | 363 | 73 364 | 365 | 366 | 367 | connectionsAmountLabel 368 | 369 | 370 | 371 | 74 372 | 373 | 374 | 375 | queuedAmountLabel 376 | 377 | 378 | 379 | 75 380 | 381 | 382 | 383 | 384 | 385 | 0 386 | 387 | 388 | 389 | 390 | 391 | -1 392 | 393 | 394 | File's Owner 395 | 396 | 397 | -2 398 | 399 | 400 | 401 | 402 | 68 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 4 412 | 413 | 414 | 415 | 416 | 16 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 63 429 | 430 | 431 | 432 | 433 | 62 434 | 435 | 436 | 437 | 438 | 61 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 57 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 49 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 44 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 45 472 | 473 | 474 | 475 | 476 | 46 477 | 478 | 479 | 480 | 481 | 54 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 56 491 | 492 | 493 | 494 | 495 | 55 496 | 497 | 498 | 499 | 500 | 58 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 60 510 | 511 | 512 | 513 | 514 | 59 515 | 516 | 517 | 518 | 519 | 520 | 521 | ViewController 522 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 523 | UIResponder 524 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 525 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 526 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 527 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 528 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 529 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 530 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 531 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 532 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 533 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 534 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 535 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 536 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 537 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 538 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 539 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 540 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 541 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 542 | 543 | 544 | 545 | 546 | 547 | 75 548 | 549 | 550 | 551 | 552 | ViewController 553 | UIViewController 554 | 555 | UILabel 556 | UILabel 557 | UILabel 558 | UITextView 559 | UIToolbar 560 | 561 | 562 | 563 | activeAmountLabel 564 | UILabel 565 | 566 | 567 | connectionsAmountLabel 568 | UILabel 569 | 570 | 571 | queuedAmountLabel 572 | UILabel 573 | 574 | 575 | textView 576 | UITextView 577 | 578 | 579 | toolbar 580 | UIToolbar 581 | 582 | 583 | 584 | IBProjectSource 585 | ./Classes/ViewController.h 586 | 587 | 588 | 589 | 590 | 0 591 | IBCocoaTouchFramework 592 | YES 593 | 3 594 | 1875 595 | 596 | 597 | -------------------------------------------------------------------------------- /iPhone Demo/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /iPhone Demo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // DCTConnectionControllerDemo 4 | // 5 | // Created by Daniel Tull on 25.06.2012. 6 | // Copyright (c) 2012 Daniel Tull. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "AppDelegate.h" 12 | 13 | int main(int argc, char *argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | --------------------------------------------------------------------------------