├── ImageTransfer.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── HenryLong.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── HenryLong.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── ImageTransfer.xcscheme │ ├── ImageTransferExtension.xcscheme │ └── xcschememanagement.plist ├── ImageTransfer ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── ImageTransfer.entitlements ├── Images │ ├── Placeholder.png │ └── Qisda.jpg ├── Info.plist ├── ReceivingFileServer.h ├── ReceivingFileServer.m ├── SendingFileClient.h ├── SendingFileClient.m ├── SendingViewController.h ├── SendingViewController.m ├── SendingViewController.xib └── main.m ├── ImageTransferExtension ├── ImageTransferExtension.entitlements ├── Info.plist ├── ShareViewController.h └── ShareViewController.m ├── LICENSE └── README.md /ImageTransfer.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 410C190C1C97D440006C20F7 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 410C190B1C97D440006C20F7 /* main.m */; }; 11 | 410C190F1C97D440006C20F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 410C190E1C97D440006C20F7 /* AppDelegate.m */; }; 12 | 410C19171C97D440006C20F7 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 410C19161C97D440006C20F7 /* Assets.xcassets */; }; 13 | 410C19291C97D78F006C20F7 /* SendingViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 410C19261C97D78F006C20F7 /* SendingViewController.m */; }; 14 | 410C192A1C97D78F006C20F7 /* SendingViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 410C19271C97D78F006C20F7 /* SendingViewController.xib */; }; 15 | 410C192D1C97D8A6006C20F7 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 410C192C1C97D8A6006C20F7 /* UIKit.framework */; }; 16 | 410C192F1C97D8B3006C20F7 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 410C192E1C97D8B3006C20F7 /* Foundation.framework */; }; 17 | 410C19311C97D8BF006C20F7 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 410C19301C97D8BF006C20F7 /* CoreGraphics.framework */; }; 18 | 410C19351C97DDB7006C20F7 /* Placeholder.png in Resources */ = {isa = PBXBuildFile; fileRef = 410C19341C97DDB7006C20F7 /* Placeholder.png */; }; 19 | 410F23201DE80F3A00CE1236 /* ShareViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 410F231F1DE80F3A00CE1236 /* ShareViewController.m */; }; 20 | 410F23271DE80F3A00CE1236 /* ImageTransferExtension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 410F231C1DE80F3A00CE1236 /* ImageTransferExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 21 | 413138A21CA3D51500A9550F /* Qisda.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 413138A11CA3D51500A9550F /* Qisda.jpg */; }; 22 | 41AD2F8C1E0BD0D400128680 /* ReceivingFileServer.m in Sources */ = {isa = PBXBuildFile; fileRef = 41AD2F8B1E0BD0D400128680 /* ReceivingFileServer.m */; }; 23 | 41AD2F8F1E0D0DD000128680 /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 41AD2F8E1E0D0DD000128680 /* MobileCoreServices.framework */; }; 24 | 41DA98D31E03972500D82F98 /* SendingFileClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 41DA98D11E03972500D82F98 /* SendingFileClient.m */; }; 25 | /* End PBXBuildFile section */ 26 | 27 | /* Begin PBXContainerItemProxy section */ 28 | 410F23251DE80F3A00CE1236 /* PBXContainerItemProxy */ = { 29 | isa = PBXContainerItemProxy; 30 | containerPortal = 410C18FF1C97D440006C20F7 /* Project object */; 31 | proxyType = 1; 32 | remoteGlobalIDString = 410F231B1DE80F3A00CE1236; 33 | remoteInfo = ImageTransferExtension; 34 | }; 35 | /* End PBXContainerItemProxy section */ 36 | 37 | /* Begin PBXCopyFilesBuildPhase section */ 38 | 410F232B1DE80F3A00CE1236 /* Embed App Extensions */ = { 39 | isa = PBXCopyFilesBuildPhase; 40 | buildActionMask = 2147483647; 41 | dstPath = ""; 42 | dstSubfolderSpec = 13; 43 | files = ( 44 | 410F23271DE80F3A00CE1236 /* ImageTransferExtension.appex in Embed App Extensions */, 45 | ); 46 | name = "Embed App Extensions"; 47 | runOnlyForDeploymentPostprocessing = 0; 48 | }; 49 | /* End PBXCopyFilesBuildPhase section */ 50 | 51 | /* Begin PBXFileReference section */ 52 | 410C19071C97D440006C20F7 /* ImageTransfer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ImageTransfer.app; sourceTree = BUILT_PRODUCTS_DIR; }; 53 | 410C190B1C97D440006C20F7 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 54 | 410C190D1C97D440006C20F7 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 55 | 410C190E1C97D440006C20F7 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 56 | 410C19161C97D440006C20F7 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 57 | 410C191B1C97D440006C20F7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 58 | 410C19251C97D78F006C20F7 /* SendingViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SendingViewController.h; sourceTree = ""; }; 59 | 410C19261C97D78F006C20F7 /* SendingViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SendingViewController.m; sourceTree = ""; }; 60 | 410C19271C97D78F006C20F7 /* SendingViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SendingViewController.xib; sourceTree = ""; }; 61 | 410C192C1C97D8A6006C20F7 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 62 | 410C192E1C97D8B3006C20F7 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 63 | 410C19301C97D8BF006C20F7 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 64 | 410C19341C97DDB7006C20F7 /* Placeholder.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Placeholder.png; sourceTree = ""; }; 65 | 410F231C1DE80F3A00CE1236 /* ImageTransferExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = ImageTransferExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; }; 66 | 410F231E1DE80F3A00CE1236 /* ShareViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ShareViewController.h; sourceTree = ""; }; 67 | 410F231F1DE80F3A00CE1236 /* ShareViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ShareViewController.m; sourceTree = ""; }; 68 | 410F23241DE80F3A00CE1236 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 69 | 413138A11CA3D51500A9550F /* Qisda.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = Qisda.jpg; sourceTree = ""; }; 70 | 41AD2F8A1E0BD0D400128680 /* ReceivingFileServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReceivingFileServer.h; sourceTree = ""; }; 71 | 41AD2F8B1E0BD0D400128680 /* ReceivingFileServer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ReceivingFileServer.m; sourceTree = ""; }; 72 | 41AD2F8E1E0D0DD000128680 /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = System/Library/Frameworks/MobileCoreServices.framework; sourceTree = SDKROOT; }; 73 | 41AD2F901E10AADE00128680 /* ImageTransferExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = ImageTransferExtension.entitlements; sourceTree = ""; }; 74 | 41AD2F911E10AB0A00128680 /* ImageTransfer.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = ImageTransfer.entitlements; sourceTree = ""; }; 75 | 41DA98D01E03972500D82F98 /* SendingFileClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SendingFileClient.h; sourceTree = ""; }; 76 | 41DA98D11E03972500D82F98 /* SendingFileClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SendingFileClient.m; sourceTree = ""; }; 77 | /* End PBXFileReference section */ 78 | 79 | /* Begin PBXFrameworksBuildPhase section */ 80 | 410C19041C97D440006C20F7 /* Frameworks */ = { 81 | isa = PBXFrameworksBuildPhase; 82 | buildActionMask = 2147483647; 83 | files = ( 84 | 410C19311C97D8BF006C20F7 /* CoreGraphics.framework in Frameworks */, 85 | 410C192F1C97D8B3006C20F7 /* Foundation.framework in Frameworks */, 86 | 410C192D1C97D8A6006C20F7 /* UIKit.framework in Frameworks */, 87 | ); 88 | runOnlyForDeploymentPostprocessing = 0; 89 | }; 90 | 410F23191DE80F3A00CE1236 /* Frameworks */ = { 91 | isa = PBXFrameworksBuildPhase; 92 | buildActionMask = 2147483647; 93 | files = ( 94 | 41AD2F8F1E0D0DD000128680 /* MobileCoreServices.framework in Frameworks */, 95 | ); 96 | runOnlyForDeploymentPostprocessing = 0; 97 | }; 98 | /* End PBXFrameworksBuildPhase section */ 99 | 100 | /* Begin PBXGroup section */ 101 | 410C18FE1C97D440006C20F7 = { 102 | isa = PBXGroup; 103 | children = ( 104 | 410C19091C97D440006C20F7 /* ImageTransfer */, 105 | 410C19321C97D8CC006C20F7 /* Framework */, 106 | 410F231D1DE80F3A00CE1236 /* ImageTransferExtension */, 107 | 410C19081C97D440006C20F7 /* Products */, 108 | 41AD2F8D1E0D0DCF00128680 /* Frameworks */, 109 | ); 110 | sourceTree = ""; 111 | }; 112 | 410C19081C97D440006C20F7 /* Products */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | 410C19071C97D440006C20F7 /* ImageTransfer.app */, 116 | 410F231C1DE80F3A00CE1236 /* ImageTransferExtension.appex */, 117 | ); 118 | name = Products; 119 | sourceTree = ""; 120 | }; 121 | 410C19091C97D440006C20F7 /* ImageTransfer */ = { 122 | isa = PBXGroup; 123 | children = ( 124 | 41AD2F911E10AB0A00128680 /* ImageTransfer.entitlements */, 125 | 410C190D1C97D440006C20F7 /* AppDelegate.h */, 126 | 410C190E1C97D440006C20F7 /* AppDelegate.m */, 127 | 410C19251C97D78F006C20F7 /* SendingViewController.h */, 128 | 410C19261C97D78F006C20F7 /* SendingViewController.m */, 129 | 410C19271C97D78F006C20F7 /* SendingViewController.xib */, 130 | 410C192B1C97D79C006C20F7 /* Sending */, 131 | 41DA98D41E03972D00D82F98 /* Receiving */, 132 | 410C19161C97D440006C20F7 /* Assets.xcassets */, 133 | 410C191B1C97D440006C20F7 /* Info.plist */, 134 | 410C190A1C97D440006C20F7 /* Supporting Files */, 135 | ); 136 | path = ImageTransfer; 137 | sourceTree = ""; 138 | }; 139 | 410C190A1C97D440006C20F7 /* Supporting Files */ = { 140 | isa = PBXGroup; 141 | children = ( 142 | 410C19331C97DDB7006C20F7 /* Images */, 143 | 410C190B1C97D440006C20F7 /* main.m */, 144 | ); 145 | name = "Supporting Files"; 146 | sourceTree = ""; 147 | }; 148 | 410C192B1C97D79C006C20F7 /* Sending */ = { 149 | isa = PBXGroup; 150 | children = ( 151 | 41DA98D01E03972500D82F98 /* SendingFileClient.h */, 152 | 41DA98D11E03972500D82F98 /* SendingFileClient.m */, 153 | ); 154 | name = Sending; 155 | sourceTree = ""; 156 | }; 157 | 410C19321C97D8CC006C20F7 /* Framework */ = { 158 | isa = PBXGroup; 159 | children = ( 160 | 410C19301C97D8BF006C20F7 /* CoreGraphics.framework */, 161 | 410C192E1C97D8B3006C20F7 /* Foundation.framework */, 162 | 410C192C1C97D8A6006C20F7 /* UIKit.framework */, 163 | ); 164 | name = Framework; 165 | sourceTree = ""; 166 | }; 167 | 410C19331C97DDB7006C20F7 /* Images */ = { 168 | isa = PBXGroup; 169 | children = ( 170 | 413138A11CA3D51500A9550F /* Qisda.jpg */, 171 | 410C19341C97DDB7006C20F7 /* Placeholder.png */, 172 | ); 173 | path = Images; 174 | sourceTree = ""; 175 | }; 176 | 410F231D1DE80F3A00CE1236 /* ImageTransferExtension */ = { 177 | isa = PBXGroup; 178 | children = ( 179 | 41AD2F901E10AADE00128680 /* ImageTransferExtension.entitlements */, 180 | 410F231E1DE80F3A00CE1236 /* ShareViewController.h */, 181 | 410F231F1DE80F3A00CE1236 /* ShareViewController.m */, 182 | 410F23241DE80F3A00CE1236 /* Info.plist */, 183 | ); 184 | path = ImageTransferExtension; 185 | sourceTree = ""; 186 | }; 187 | 41AD2F8D1E0D0DCF00128680 /* Frameworks */ = { 188 | isa = PBXGroup; 189 | children = ( 190 | 41AD2F8E1E0D0DD000128680 /* MobileCoreServices.framework */, 191 | ); 192 | name = Frameworks; 193 | sourceTree = ""; 194 | }; 195 | 41DA98D41E03972D00D82F98 /* Receiving */ = { 196 | isa = PBXGroup; 197 | children = ( 198 | 41AD2F8A1E0BD0D400128680 /* ReceivingFileServer.h */, 199 | 41AD2F8B1E0BD0D400128680 /* ReceivingFileServer.m */, 200 | ); 201 | name = Receiving; 202 | sourceTree = ""; 203 | }; 204 | /* End PBXGroup section */ 205 | 206 | /* Begin PBXNativeTarget section */ 207 | 410C19061C97D440006C20F7 /* ImageTransfer */ = { 208 | isa = PBXNativeTarget; 209 | buildConfigurationList = 410C191E1C97D440006C20F7 /* Build configuration list for PBXNativeTarget "ImageTransfer" */; 210 | buildPhases = ( 211 | 410C19031C97D440006C20F7 /* Sources */, 212 | 410C19041C97D440006C20F7 /* Frameworks */, 213 | 410C19051C97D440006C20F7 /* Resources */, 214 | 410F232B1DE80F3A00CE1236 /* Embed App Extensions */, 215 | ); 216 | buildRules = ( 217 | ); 218 | dependencies = ( 219 | 410F23261DE80F3A00CE1236 /* PBXTargetDependency */, 220 | ); 221 | name = ImageTransfer; 222 | productName = ImageTransfer; 223 | productReference = 410C19071C97D440006C20F7 /* ImageTransfer.app */; 224 | productType = "com.apple.product-type.application"; 225 | }; 226 | 410F231B1DE80F3A00CE1236 /* ImageTransferExtension */ = { 227 | isa = PBXNativeTarget; 228 | buildConfigurationList = 410F232A1DE80F3A00CE1236 /* Build configuration list for PBXNativeTarget "ImageTransferExtension" */; 229 | buildPhases = ( 230 | 410F23181DE80F3A00CE1236 /* Sources */, 231 | 410F23191DE80F3A00CE1236 /* Frameworks */, 232 | 410F231A1DE80F3A00CE1236 /* Resources */, 233 | ); 234 | buildRules = ( 235 | ); 236 | dependencies = ( 237 | ); 238 | name = ImageTransferExtension; 239 | productName = ImageTransferExtension; 240 | productReference = 410F231C1DE80F3A00CE1236 /* ImageTransferExtension.appex */; 241 | productType = "com.apple.product-type.app-extension"; 242 | }; 243 | /* End PBXNativeTarget section */ 244 | 245 | /* Begin PBXProject section */ 246 | 410C18FF1C97D440006C20F7 /* Project object */ = { 247 | isa = PBXProject; 248 | attributes = { 249 | LastUpgradeCheck = 0810; 250 | ORGANIZATIONNAME = qisda; 251 | TargetAttributes = { 252 | 410C19061C97D440006C20F7 = { 253 | CreatedOnToolsVersion = 7.2.1; 254 | DevelopmentTeam = 9A883W693P; 255 | SystemCapabilities = { 256 | com.apple.ApplicationGroups.iOS = { 257 | enabled = 1; 258 | }; 259 | }; 260 | }; 261 | 410F231B1DE80F3A00CE1236 = { 262 | CreatedOnToolsVersion = 8.1; 263 | DevelopmentTeam = 9A883W693P; 264 | ProvisioningStyle = Automatic; 265 | SystemCapabilities = { 266 | com.apple.ApplicationGroups.iOS = { 267 | enabled = 1; 268 | }; 269 | }; 270 | }; 271 | }; 272 | }; 273 | buildConfigurationList = 410C19021C97D440006C20F7 /* Build configuration list for PBXProject "ImageTransfer" */; 274 | compatibilityVersion = "Xcode 3.2"; 275 | developmentRegion = English; 276 | hasScannedForEncodings = 0; 277 | knownRegions = ( 278 | en, 279 | Base, 280 | ); 281 | mainGroup = 410C18FE1C97D440006C20F7; 282 | productRefGroup = 410C19081C97D440006C20F7 /* Products */; 283 | projectDirPath = ""; 284 | projectRoot = ""; 285 | targets = ( 286 | 410C19061C97D440006C20F7 /* ImageTransfer */, 287 | 410F231B1DE80F3A00CE1236 /* ImageTransferExtension */, 288 | ); 289 | }; 290 | /* End PBXProject section */ 291 | 292 | /* Begin PBXResourcesBuildPhase section */ 293 | 410C19051C97D440006C20F7 /* Resources */ = { 294 | isa = PBXResourcesBuildPhase; 295 | buildActionMask = 2147483647; 296 | files = ( 297 | 410C192A1C97D78F006C20F7 /* SendingViewController.xib in Resources */, 298 | 410C19351C97DDB7006C20F7 /* Placeholder.png in Resources */, 299 | 413138A21CA3D51500A9550F /* Qisda.jpg in Resources */, 300 | 410C19171C97D440006C20F7 /* Assets.xcassets in Resources */, 301 | ); 302 | runOnlyForDeploymentPostprocessing = 0; 303 | }; 304 | 410F231A1DE80F3A00CE1236 /* Resources */ = { 305 | isa = PBXResourcesBuildPhase; 306 | buildActionMask = 2147483647; 307 | files = ( 308 | ); 309 | runOnlyForDeploymentPostprocessing = 0; 310 | }; 311 | /* End PBXResourcesBuildPhase section */ 312 | 313 | /* Begin PBXSourcesBuildPhase section */ 314 | 410C19031C97D440006C20F7 /* Sources */ = { 315 | isa = PBXSourcesBuildPhase; 316 | buildActionMask = 2147483647; 317 | files = ( 318 | 410C190F1C97D440006C20F7 /* AppDelegate.m in Sources */, 319 | 41AD2F8C1E0BD0D400128680 /* ReceivingFileServer.m in Sources */, 320 | 410C19291C97D78F006C20F7 /* SendingViewController.m in Sources */, 321 | 410C190C1C97D440006C20F7 /* main.m in Sources */, 322 | 41DA98D31E03972500D82F98 /* SendingFileClient.m in Sources */, 323 | ); 324 | runOnlyForDeploymentPostprocessing = 0; 325 | }; 326 | 410F23181DE80F3A00CE1236 /* Sources */ = { 327 | isa = PBXSourcesBuildPhase; 328 | buildActionMask = 2147483647; 329 | files = ( 330 | 410F23201DE80F3A00CE1236 /* ShareViewController.m in Sources */, 331 | ); 332 | runOnlyForDeploymentPostprocessing = 0; 333 | }; 334 | /* End PBXSourcesBuildPhase section */ 335 | 336 | /* Begin PBXTargetDependency section */ 337 | 410F23261DE80F3A00CE1236 /* PBXTargetDependency */ = { 338 | isa = PBXTargetDependency; 339 | target = 410F231B1DE80F3A00CE1236 /* ImageTransferExtension */; 340 | targetProxy = 410F23251DE80F3A00CE1236 /* PBXContainerItemProxy */; 341 | }; 342 | /* End PBXTargetDependency section */ 343 | 344 | /* Begin XCBuildConfiguration section */ 345 | 410C191C1C97D440006C20F7 /* Debug */ = { 346 | isa = XCBuildConfiguration; 347 | buildSettings = { 348 | ALWAYS_SEARCH_USER_PATHS = NO; 349 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 350 | CLANG_CXX_LIBRARY = "libc++"; 351 | CLANG_ENABLE_MODULES = YES; 352 | CLANG_ENABLE_OBJC_ARC = YES; 353 | CLANG_WARN_BOOL_CONVERSION = YES; 354 | CLANG_WARN_CONSTANT_CONVERSION = YES; 355 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 356 | CLANG_WARN_EMPTY_BODY = YES; 357 | CLANG_WARN_ENUM_CONVERSION = YES; 358 | CLANG_WARN_INFINITE_RECURSION = YES; 359 | CLANG_WARN_INT_CONVERSION = YES; 360 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 361 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 362 | CLANG_WARN_UNREACHABLE_CODE = YES; 363 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 364 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 365 | COPY_PHASE_STRIP = NO; 366 | DEBUG_INFORMATION_FORMAT = dwarf; 367 | ENABLE_STRICT_OBJC_MSGSEND = YES; 368 | ENABLE_TESTABILITY = YES; 369 | GCC_C_LANGUAGE_STANDARD = gnu99; 370 | GCC_DYNAMIC_NO_PIC = NO; 371 | GCC_NO_COMMON_BLOCKS = YES; 372 | GCC_OPTIMIZATION_LEVEL = 0; 373 | GCC_PREPROCESSOR_DEFINITIONS = ( 374 | "DEBUG=1", 375 | "$(inherited)", 376 | ); 377 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 378 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 379 | GCC_WARN_UNDECLARED_SELECTOR = YES; 380 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 381 | GCC_WARN_UNUSED_FUNCTION = YES; 382 | GCC_WARN_UNUSED_VARIABLE = YES; 383 | IPHONEOS_DEPLOYMENT_TARGET = 10.1; 384 | MTL_ENABLE_DEBUG_INFO = YES; 385 | ONLY_ACTIVE_ARCH = YES; 386 | SDKROOT = iphoneos; 387 | TARGETED_DEVICE_FAMILY = "1,2"; 388 | }; 389 | name = Debug; 390 | }; 391 | 410C191D1C97D440006C20F7 /* Release */ = { 392 | isa = XCBuildConfiguration; 393 | buildSettings = { 394 | ALWAYS_SEARCH_USER_PATHS = NO; 395 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 396 | CLANG_CXX_LIBRARY = "libc++"; 397 | CLANG_ENABLE_MODULES = YES; 398 | CLANG_ENABLE_OBJC_ARC = YES; 399 | CLANG_WARN_BOOL_CONVERSION = YES; 400 | CLANG_WARN_CONSTANT_CONVERSION = YES; 401 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 402 | CLANG_WARN_EMPTY_BODY = YES; 403 | CLANG_WARN_ENUM_CONVERSION = YES; 404 | CLANG_WARN_INFINITE_RECURSION = YES; 405 | CLANG_WARN_INT_CONVERSION = YES; 406 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 407 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 408 | CLANG_WARN_UNREACHABLE_CODE = YES; 409 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 410 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 411 | COPY_PHASE_STRIP = NO; 412 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 413 | ENABLE_NS_ASSERTIONS = NO; 414 | ENABLE_STRICT_OBJC_MSGSEND = YES; 415 | GCC_C_LANGUAGE_STANDARD = gnu99; 416 | GCC_NO_COMMON_BLOCKS = YES; 417 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 418 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 419 | GCC_WARN_UNDECLARED_SELECTOR = YES; 420 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 421 | GCC_WARN_UNUSED_FUNCTION = YES; 422 | GCC_WARN_UNUSED_VARIABLE = YES; 423 | IPHONEOS_DEPLOYMENT_TARGET = 10.1; 424 | MTL_ENABLE_DEBUG_INFO = NO; 425 | SDKROOT = iphoneos; 426 | TARGETED_DEVICE_FAMILY = "1,2"; 427 | VALIDATE_PRODUCT = YES; 428 | }; 429 | name = Release; 430 | }; 431 | 410C191F1C97D440006C20F7 /* Debug */ = { 432 | isa = XCBuildConfiguration; 433 | buildSettings = { 434 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 435 | CODE_SIGN_ENTITLEMENTS = ImageTransfer/ImageTransfer.entitlements; 436 | CODE_SIGN_IDENTITY = "iPhone Developer"; 437 | INFOPLIST_FILE = ImageTransfer/Info.plist; 438 | IPHONEOS_DEPLOYMENT_TARGET = 10.1; 439 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 440 | PRODUCT_BUNDLE_IDENTIFIER = com.oem.ios.ImageTransfer; 441 | PRODUCT_NAME = "$(TARGET_NAME)"; 442 | TARGETED_DEVICE_FAMILY = "1,2"; 443 | }; 444 | name = Debug; 445 | }; 446 | 410C19201C97D440006C20F7 /* Release */ = { 447 | isa = XCBuildConfiguration; 448 | buildSettings = { 449 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 450 | CODE_SIGN_ENTITLEMENTS = ImageTransfer/ImageTransfer.entitlements; 451 | CODE_SIGN_IDENTITY = "iPhone Developer"; 452 | INFOPLIST_FILE = ImageTransfer/Info.plist; 453 | IPHONEOS_DEPLOYMENT_TARGET = 10.1; 454 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 455 | PRODUCT_BUNDLE_IDENTIFIER = com.oem.ios.ImageTransfer; 456 | PRODUCT_NAME = "$(TARGET_NAME)"; 457 | TARGETED_DEVICE_FAMILY = "1,2"; 458 | }; 459 | name = Release; 460 | }; 461 | 410F23281DE80F3A00CE1236 /* Debug */ = { 462 | isa = XCBuildConfiguration; 463 | buildSettings = { 464 | CLANG_ANALYZER_NONNULL = YES; 465 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 466 | CLANG_WARN_INFINITE_RECURSION = YES; 467 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 468 | CODE_SIGN_ENTITLEMENTS = ImageTransferExtension/ImageTransferExtension.entitlements; 469 | CODE_SIGN_IDENTITY = "iPhone Developer"; 470 | DEVELOPMENT_TEAM = 9A883W693P; 471 | INFOPLIST_FILE = ImageTransferExtension/Info.plist; 472 | IPHONEOS_DEPLOYMENT_TARGET = 10.1; 473 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; 474 | PRODUCT_BUNDLE_IDENTIFIER = com.oem.ios.ImageTransfer.ImageTransferExtension; 475 | PRODUCT_NAME = "$(TARGET_NAME)"; 476 | SKIP_INSTALL = YES; 477 | TARGETED_DEVICE_FAMILY = "1,2"; 478 | }; 479 | name = Debug; 480 | }; 481 | 410F23291DE80F3A00CE1236 /* Release */ = { 482 | isa = XCBuildConfiguration; 483 | buildSettings = { 484 | CLANG_ANALYZER_NONNULL = YES; 485 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 486 | CLANG_WARN_INFINITE_RECURSION = YES; 487 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 488 | CODE_SIGN_ENTITLEMENTS = ImageTransferExtension/ImageTransferExtension.entitlements; 489 | CODE_SIGN_IDENTITY = "iPhone Developer"; 490 | DEVELOPMENT_TEAM = 9A883W693P; 491 | INFOPLIST_FILE = ImageTransferExtension/Info.plist; 492 | IPHONEOS_DEPLOYMENT_TARGET = 10.1; 493 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; 494 | PRODUCT_BUNDLE_IDENTIFIER = com.oem.ios.ImageTransfer.ImageTransferExtension; 495 | PRODUCT_NAME = "$(TARGET_NAME)"; 496 | SKIP_INSTALL = YES; 497 | TARGETED_DEVICE_FAMILY = "1,2"; 498 | }; 499 | name = Release; 500 | }; 501 | /* End XCBuildConfiguration section */ 502 | 503 | /* Begin XCConfigurationList section */ 504 | 410C19021C97D440006C20F7 /* Build configuration list for PBXProject "ImageTransfer" */ = { 505 | isa = XCConfigurationList; 506 | buildConfigurations = ( 507 | 410C191C1C97D440006C20F7 /* Debug */, 508 | 410C191D1C97D440006C20F7 /* Release */, 509 | ); 510 | defaultConfigurationIsVisible = 0; 511 | defaultConfigurationName = Release; 512 | }; 513 | 410C191E1C97D440006C20F7 /* Build configuration list for PBXNativeTarget "ImageTransfer" */ = { 514 | isa = XCConfigurationList; 515 | buildConfigurations = ( 516 | 410C191F1C97D440006C20F7 /* Debug */, 517 | 410C19201C97D440006C20F7 /* Release */, 518 | ); 519 | defaultConfigurationIsVisible = 0; 520 | defaultConfigurationName = Release; 521 | }; 522 | 410F232A1DE80F3A00CE1236 /* Build configuration list for PBXNativeTarget "ImageTransferExtension" */ = { 523 | isa = XCConfigurationList; 524 | buildConfigurations = ( 525 | 410F23281DE80F3A00CE1236 /* Debug */, 526 | 410F23291DE80F3A00CE1236 /* Release */, 527 | ); 528 | defaultConfigurationIsVisible = 0; 529 | defaultConfigurationName = Release; 530 | }; 531 | /* End XCConfigurationList section */ 532 | }; 533 | rootObject = 410C18FF1C97D440006C20F7 /* Project object */; 534 | } 535 | -------------------------------------------------------------------------------- /ImageTransfer.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ImageTransfer.xcodeproj/project.xcworkspace/xcuserdata/HenryLong.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HenryLong/ImageTransferiOS/b751ce351df8d9d866d2cd725d42deb1bb1e8d1d/ImageTransfer.xcodeproj/project.xcworkspace/xcuserdata/HenryLong.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /ImageTransfer.xcodeproj/xcuserdata/HenryLong.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 20 | 21 | 22 | 24 | 36 | 37 | 38 | 40 | 52 | 53 | 54 | 56 | 68 | 69 | 70 | 72 | 84 | 85 | 86 | 88 | 100 | 101 | 102 | 104 | 116 | 117 | 118 | 120 | 132 | 133 | 134 | 136 | 148 | 149 | 150 | 151 | 152 | -------------------------------------------------------------------------------- /ImageTransfer.xcodeproj/xcuserdata/HenryLong.xcuserdatad/xcschemes/ImageTransfer.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /ImageTransfer.xcodeproj/xcuserdata/HenryLong.xcuserdatad/xcschemes/ImageTransferExtension.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 6 | 9 | 10 | 16 | 22 | 23 | 24 | 30 | 36 | 37 | 38 | 39 | 40 | 45 | 46 | 47 | 48 | 54 | 55 | 56 | 57 | 58 | 59 | 70 | 72 | 78 | 79 | 80 | 81 | 82 | 83 | 90 | 92 | 98 | 99 | 100 | 101 | 103 | 104 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /ImageTransfer.xcodeproj/xcuserdata/HenryLong.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ImageTransfer.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | ImageTransferExtension.xcscheme 13 | 14 | orderHint 15 | 1 16 | 17 | 18 | SuppressBuildableAutocreation 19 | 20 | 410C19061C97D440006C20F7 21 | 22 | primary 23 | 24 | 25 | 410F231B1DE80F3A00CE1236 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /ImageTransfer/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // ImageTransfer 4 | // 5 | // Created by LongHenry on 2016/3/15. 6 | // Copyright © 2016年 qisda. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "SendingViewController.h" 11 | 12 | @class ViewController; 13 | 14 | @interface AppDelegate : UIResponder 15 | 16 | @property (strong, nonatomic) UIWindow *window; 17 | @property (strong, nonatomic) SendingViewController *viewController; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /ImageTransfer/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // ImageTransfer 4 | // 5 | // Created by LongHenry on 2016/3/15. 6 | // Copyright © 2016年 qisda. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @implementation AppDelegate 12 | 13 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 14 | { 15 | //NSLog(@"didFinishLaunchingWithOptions"); 16 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 17 | self.viewController = [[SendingViewController alloc] initWithNibName:@"SendingViewController" bundle:nil]; 18 | self.window.rootViewController = self.viewController; 19 | [self.window makeKeyAndVisible]; 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application 24 | { 25 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 26 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 27 | } 28 | 29 | - (void)applicationDidEnterBackground:(UIApplication *)application 30 | { 31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | - (void)applicationWillEnterForeground:(UIApplication *)application 36 | { 37 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 38 | } 39 | 40 | - (void)applicationDidBecomeActive:(UIApplication *)application 41 | { 42 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 43 | } 44 | 45 | - (void)applicationWillTerminate:(UIApplication *)application 46 | { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary *)options 52 | { 53 | NSLog(@"Launch url: %@", url); 54 | [self readFromExtension]; 55 | 56 | if(self.viewController.imageArrayData.count != 0){ 57 | [self.viewController processImageList]; 58 | } 59 | return YES; 60 | } 61 | 62 | - (void)readFromExtension{ 63 | NSUserDefaults *shared = [[NSUserDefaults alloc] initWithSuiteName:@"group.ios.image.share"]; 64 | NSMutableArray *url = [shared valueForKey:@"url"]; 65 | NSMutableArray *imageData = [shared valueForKey:@"imageData"] ; 66 | 67 | NSLog(@"readUrlFromExtension url: %@", url); 68 | NSLog(@"readUrlFromExtension imageData: %@", imageData); 69 | 70 | self.viewController.imageArrayUrl = [NSMutableArray arrayWithArray:url]; 71 | self.viewController.imageArrayData = [NSMutableArray arrayWithArray:imageData]; 72 | 73 | [shared removeObjectForKey:@"url"]; // delete key after read 74 | [shared removeObjectForKey:@"imageData"]; // delete key after read 75 | } 76 | 77 | 78 | @end 79 | 80 | -------------------------------------------------------------------------------- /ImageTransfer/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | } 88 | ], 89 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /ImageTransfer/ImageTransfer.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.application-groups 6 | 7 | group.ios.image.share 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /ImageTransfer/Images/Placeholder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HenryLong/ImageTransferiOS/b751ce351df8d9d866d2cd725d42deb1bb1e8d1d/ImageTransfer/Images/Placeholder.png -------------------------------------------------------------------------------- /ImageTransfer/Images/Qisda.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HenryLong/ImageTransferiOS/b751ce351df8d9d866d2cd725d42deb1bb1e8d1d/ImageTransfer/Images/Qisda.jpg -------------------------------------------------------------------------------- /ImageTransfer/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleURLTypes 22 | 23 | 24 | CFBundleTypeRole 25 | Editor 26 | CFBundleURLName 27 | com.oem.ios.ImageTransfer.ImageShare 28 | CFBundleURLSchemes 29 | 30 | ImageShare 31 | 32 | 33 | 34 | CFBundleVersion 35 | 1 36 | LSRequiresIPhoneOS 37 | 38 | NSHumanReadableCopyright 39 | Copyright © 2016年 Qisda. All rights reserved. 40 | NSPhotoLibraryUsageDescription 41 | ALLOW TO ACCESS PHOTO? 42 | UILaunchStoryboardName 43 | SendingViewController 44 | UIRequiredDeviceCapabilities 45 | 46 | armv7 47 | 48 | UISupportedInterfaceOrientations 49 | 50 | UIInterfaceOrientationPortrait 51 | UIInterfaceOrientationLandscapeLeft 52 | UIInterfaceOrientationLandscapeRight 53 | 54 | UISupportedInterfaceOrientations~ipad 55 | 56 | UIInterfaceOrientationPortrait 57 | UIInterfaceOrientationPortraitUpsideDown 58 | UIInterfaceOrientationLandscapeLeft 59 | UIInterfaceOrientationLandscapeRight 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /ImageTransfer/ReceivingFileServer.h: -------------------------------------------------------------------------------- 1 | // 2 | // RecevingFileServer.h 3 | // ImageTransfer 4 | // 5 | // Created by LongHenry on 2016/11/18. 6 | // Copyright © 2016年 qisda. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @class SendingViewController; 13 | 14 | @interface ReceivingFileServer : NSObject { 15 | NSMutableData *data; 16 | NSString *fileName; 17 | BOOL isHeader; 18 | } 19 | 20 | @property (nonatomic, weak) SendingViewController *mViewController; 21 | 22 | - (int)setup; 23 | - (void)setview : (SendingViewController *)viewController; 24 | - (void)saveImage: (UIImage*)image; 25 | 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /ImageTransfer/ReceivingFileServer.m: -------------------------------------------------------------------------------- 1 | // 2 | // RecevingFileServer.m 3 | // ImageTransfer 4 | // 5 | // Created by LongHenry on 2016/11/18. 6 | // Copyright © 2016年 qisda. All rights reserved. 7 | // 8 | 9 | /* 10 | Core Foundation is the C-level API, which provides CFString, CFDictionary and the like. 11 | Foundation is Objective-C, which provides NSString, NSDictionary, etc. 12 | */ 13 | #import "ReceivingFileServer.h" 14 | #import "SendingViewController.h" 15 | #import 16 | #import "AssetsLibrary/AssetsLibrary.h" 17 | #import 18 | #import 19 | #import 20 | 21 | /* Port to listen on */ 22 | #define PORT 8989 23 | 24 | CFReadStreamRef readStream; 25 | 26 | @implementation ReceivingFileServer 27 | 28 | - (void)setview : (SendingViewController *) viewController{ 29 | self.mViewController = viewController; 30 | } 31 | 32 | - (int)setup { 33 | /* The server socket */ 34 | CFSocketRef TCPServer; 35 | 36 | /* Used by setsockopt */ 37 | int yes = 1; 38 | 39 | /* Build our socket context; */ 40 | CFSocketContext CTX = { 0, (__bridge void *)(self), NULL, NULL, NULL }; 41 | 42 | /* Create the server socket as a TCP IPv4 socket and set a callback */ 43 | /* for calls to the socket's lower-level accept() function */ 44 | TCPServer = CFSocketCreate(NULL, PF_INET, SOCK_STREAM, IPPROTO_TCP, 45 | kCFSocketAcceptCallBack, (CFSocketCallBack)acceptCallBack, &CTX); 46 | if (TCPServer == NULL) 47 | return EXIT_FAILURE; 48 | 49 | /* Re-use local addresses, if they're still in TIME_WAIT */ 50 | setsockopt(CFSocketGetNative(TCPServer), SOL_SOCKET, SO_REUSEADDR, 51 | (void *)&yes, sizeof(yes)); 52 | 53 | /* Set the port and address we want to listen on */ 54 | struct sockaddr_in addr; 55 | memset(&addr, 0, sizeof(addr)); 56 | addr.sin_len = sizeof(addr); 57 | addr.sin_family = AF_INET; 58 | addr.sin_port = htons(PORT); 59 | addr.sin_addr.s_addr = htonl(INADDR_ANY); 60 | 61 | NSData *address = [ NSData dataWithBytes: &addr length: sizeof(addr) ]; 62 | if (CFSocketSetAddress(TCPServer, (CFDataRef) address) != kCFSocketSuccess) { 63 | NSLog(@"CFSocketSetAddress() failed\n"); 64 | CFRelease(TCPServer); 65 | return EXIT_FAILURE; 66 | } 67 | 68 | CFRunLoopSourceRef sourceRef = CFSocketCreateRunLoopSource(kCFAllocatorDefault, TCPServer, 0); 69 | CFRunLoopAddSource(CFRunLoopGetCurrent(), sourceRef, kCFRunLoopDefaultMode); 70 | CFRelease(sourceRef); 71 | 72 | NSLog(@"Socket listening on port %d\n", PORT); 73 | 74 | //Don't run the run loop yourself on the main thread. The main event loop will run it. 75 | //CFRunLoopRun(); 76 | return 0; 77 | } 78 | 79 | static void acceptCallBack(CFSocketRef socket, CFSocketCallBackType type, CFDataRef address, const void *data, void *info) 80 | { 81 | NSLog(@"acceptCallBack"); 82 | readStream = NULL; 83 | 84 | CFOptionFlags registeredEvents = (kCFStreamEventOpenCompleted | kCFStreamEventHasBytesAvailable | 85 | kCFStreamEventEndEncountered | kCFStreamEventErrorOccurred); 86 | CFStreamClientContext ctx = {0, info, NULL, NULL, NULL}; 87 | 88 | 89 | /* The native socket, used for various operations */ 90 | CFSocketNativeHandle sock = *(CFSocketNativeHandle *) data; 91 | 92 | 93 | /* Create the read and write streams for the socket */ 94 | CFStreamCreatePairWithSocket(kCFAllocatorDefault, sock, &readStream, NULL); 95 | 96 | if (!readStream ) { 97 | close(sock); 98 | NSLog(@"CFStreamCreatePairWithSocket() failed\n"); 99 | return; 100 | } 101 | 102 | // Schedule the stream on the run loop to enable callbacks 103 | if(CFReadStreamSetClient(readStream, registeredEvents, readCallback, &ctx)) 104 | { 105 | CFReadStreamScheduleWithRunLoop(readStream, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); 106 | } 107 | 108 | if (CFReadStreamOpen(readStream) == NO) { 109 | NSLog(@"Failed to open read stream"); 110 | return; 111 | } 112 | 113 | } 114 | 115 | static void readCallback(CFReadStreamRef stream, CFStreamEventType event, void *myPtr) 116 | { 117 | 118 | ReceivingFileServer *delegate = (__bridge ReceivingFileServer *)myPtr; 119 | int kBufferSize = 1024; 120 | switch(event) { 121 | case kCFStreamEventOpenCompleted:{ 122 | NSLog(@"Stream opened!"); 123 | delegate->isHeader = true; 124 | delegate->data = [NSMutableData new]; 125 | break; 126 | } 127 | 128 | case kCFStreamEventHasBytesAvailable: { 129 | // Read bytes until there are no more 130 | // 131 | while (CFReadStreamHasBytesAvailable(stream)) { 132 | UInt8 buffer[kBufferSize]; 133 | long numBytesRead = CFReadStreamRead(stream, buffer, kBufferSize); 134 | //NSLog(@"readStream read %ld\n", numBytesRead); 135 | if (numBytesRead > 0) { 136 | if(delegate->isHeader){ 137 | uint8_t headerBuf[1024]; 138 | uint8_t len = buffer[0]; 139 | for (int i = 0 ; i < len; i ++){ 140 | headerBuf[i] = buffer[i+1]; 141 | } 142 | delegate->fileName = [[NSString alloc] initWithBytes:headerBuf length:len encoding:NSASCIIStringEncoding]; 143 | NSLog(@"fileName %@\n", delegate->fileName); 144 | delegate->isHeader = false; 145 | break; 146 | } 147 | 148 | [delegate->data appendBytes:(const void *)buffer length:numBytesRead]; 149 | } 150 | } 151 | 152 | break; 153 | } 154 | 155 | case kCFStreamEventErrorOccurred: { 156 | CFErrorRef error = CFReadStreamCopyError(stream); 157 | if (error != NULL) { 158 | if (CFErrorGetCode(error) != 0) { 159 | NSString * errorInfo = [NSString stringWithFormat:@"Failed while reading stream; error '%@' (code %ld)", (__bridge NSString*)CFErrorGetDomain(error), CFErrorGetCode(error)]; 160 | NSLog(@"errorInfo %@\n", errorInfo); 161 | } 162 | 163 | CFRelease(error); 164 | } 165 | CFReadStreamClose(stream); 166 | break; 167 | } 168 | 169 | case kCFStreamEventEndEncountered:{ 170 | // Finnish receiveing data 171 | // 172 | NSLog(@"kCFStreamEventEndEncountered"); 173 | UIImage *image = [[UIImage alloc] initWithData:delegate->data]; 174 | //NSString *home = NSHomeDirectory(); 175 | //NSString *downloads = [NSString stringWithFormat:@"%@%@", home, @"/Downloads/"]; 176 | //NSString *path = [NSString stringWithFormat:@"%@%@", downloads, delegate->fileName]; 177 | [delegate saveImage:image]; 178 | 179 | // Clean up 180 | // 181 | CFReadStreamClose(stream); 182 | CFReadStreamUnscheduleFromRunLoop(stream, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); 183 | //CFRunLoopStop(CFRunLoopGetCurrent()); 184 | 185 | break; 186 | } 187 | default: 188 | break; 189 | } 190 | } 191 | 192 | - (void)saveImage: (UIImage*)image 193 | { 194 | if (image != nil) 195 | { 196 | //Save to NSDocumentDirectory 197 | /* 198 | NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, 199 | NSUserDomainMask, YES); 200 | NSString *documentsDirectory = [paths objectAtIndex:0]; 201 | NSString* path = [documentsDirectory stringByAppendingPathComponent: 202 | [NSString stringWithString: fileName] ]; 203 | NSLog(@"path: %@", path); 204 | NSData* imageFile = UIImagePNGRepresentation(image); 205 | [imageFile writeToFile:path atomically:YES]; 206 | */ 207 | //Save to photo lib 208 | UIImageWriteToSavedPhotosAlbum(image, self, @selector(savedPhotoImage:didFinishSavingWithError:contextInfo:), nil); 209 | self.mViewController.imageView.image = image ; 210 | self.mViewController.fileName.text = fileName; 211 | 212 | /* we can't open photo app by url, so skip it 213 | ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init]; 214 | [library writeImageToSavedPhotosAlbum:[image CGImage] orientation:(ALAssetOrientation)[image imageOrientation] completionBlock:^(NSURL *assetURL, NSError *error){ 215 | if (error) { 216 | NSLog(@"error"); // oops, error ! 217 | } else { 218 | NSLog(@"url %@", assetURL); // assetURL is the url you looking for 219 | } 220 | 221 | NSString *description = [NSString stringWithFormat:@"%@ %@", fileName, @"has saved to photo lib"]; 222 | UIAlertController *alertController; 223 | UIAlertAction* defaultAction; 224 | 225 | if(error){ 226 | alertController = 227 | [UIAlertController alertControllerWithTitle:@"FAIL" 228 | message:[error description] 229 | preferredStyle:UIAlertControllerStyleAlert]; 230 | 231 | }else{ 232 | alertController = 233 | [UIAlertController alertControllerWithTitle:@"Received File" 234 | message:description 235 | preferredStyle:UIAlertControllerStyleAlert]; 236 | defaultAction = [UIAlertAction actionWithTitle:@"OPEN" 237 | style:UIAlertActionStyleDefault 238 | handler:^(UIAlertAction * action) 239 | { 240 | [self checkpermission]; 241 | [[UIApplication sharedApplication] openURL:assetURL options:@{} completionHandler: 242 | ^(BOOL success) { 243 | NSLog(@"Open %@: %d",assetURL,success); 244 | }]; 245 | 246 | 247 | 248 | }]; 249 | [alertController addAction:defaultAction]; 250 | } 251 | 252 | 253 | UIAlertAction *cancelAction =[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]; 254 | [alertController addAction:cancelAction]; 255 | 256 | [self.mViewController presentViewController:alertController animated:YES completion:nil]; 257 | }]; 258 | */ 259 | } 260 | } 261 | - (void)checkpermission{ 262 | 263 | PHAuthorizationStatus status = [PHPhotoLibrary authorizationStatus]; 264 | 265 | if (status == PHAuthorizationStatusAuthorized) { 266 | // Access has been granted. 267 | NSLog(@"Access has been granted"); 268 | } 269 | 270 | else if (status == PHAuthorizationStatusDenied) { 271 | // Access has been denied. 272 | NSLog(@"Access has been denied"); 273 | } 274 | 275 | else if (status == PHAuthorizationStatusNotDetermined) { 276 | 277 | // Access has not been determined. 278 | [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) { 279 | 280 | if (status == PHAuthorizationStatusAuthorized) { 281 | // Access has been granted. 282 | NSLog(@"Access has been Authorized"); 283 | } 284 | 285 | else { 286 | // Access has been denied. 287 | NSLog(@"Access has been rejected"); 288 | } 289 | }]; 290 | } 291 | 292 | else if (status == PHAuthorizationStatusRestricted) { 293 | // Restricted access - normally won't happen. 294 | } 295 | 296 | } 297 | - (void)savedPhotoImage:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo { 298 | 299 | 300 | NSString *description = [NSString stringWithFormat:@"%@ %@", fileName, @"has saved to photo lib"]; 301 | UIAlertController *alertController; 302 | //UIAlertAction* defaultAction; 303 | 304 | if(error){ 305 | alertController = 306 | [UIAlertController alertControllerWithTitle:@"FAIL" 307 | message:[error description] 308 | preferredStyle:UIAlertControllerStyleAlert]; 309 | 310 | }else{ 311 | alertController = 312 | [UIAlertController alertControllerWithTitle:@"Received File" 313 | message:description 314 | preferredStyle:UIAlertControllerStyleAlert]; 315 | self.mViewController.send.enabled = false; //avoid user send the received image 316 | /* we can't open photo app by url 317 | defaultAction = [UIAlertAction actionWithTitle:@"OPEN" 318 | style:UIAlertActionStyleDefault 319 | handler:^(UIAlertAction * action) 320 | { 321 | NSURL *url = [NSURL URLWithString:@"http://google.com"]; 322 | 323 | if ([[UIApplication sharedApplication] canOpenURL:url]) 324 | { 325 | [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; 326 | } 327 | 328 | }]; 329 | [alertController addAction:defaultAction]; 330 | */ 331 | } 332 | 333 | 334 | UIAlertAction *cancelAction =[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleCancel handler:nil]; 335 | [alertController addAction:cancelAction]; 336 | 337 | [self.mViewController presentViewController:alertController animated:YES completion:nil]; 338 | } 339 | 340 | 341 | 342 | @end 343 | -------------------------------------------------------------------------------- /ImageTransfer/SendingFileClient.h: -------------------------------------------------------------------------------- 1 | // 2 | // SendingFileClient.h 3 | // ImageTransfer 4 | // 5 | // Created by LongHenry on 2016/12/7. 6 | // Copyright © 2016年 qisda. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | 13 | @class SendingViewController; 14 | 15 | @interface SendingFileClient : NSObject { 16 | NSUInteger byteIndex; 17 | BOOL isHeader; 18 | NSOutputStream *outputStream; 19 | } 20 | 21 | @property (nonatomic, weak) SendingViewController *mViewController; 22 | 23 | - (void) initNetworkCommunication; 24 | - (void) setview : (SendingViewController *)viewController; 25 | 26 | @end 27 | 28 | 29 | -------------------------------------------------------------------------------- /ImageTransfer/SendingFileClient.m: -------------------------------------------------------------------------------- 1 | // 2 | // SendingFileClient.m 3 | // ImageTransfer 4 | // 5 | // Created by LongHenry on 2016/12/7. 6 | // Copyright © 2016年 qisda. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "SendingFileClient.h" 11 | #import "SendingViewController.h" 12 | 13 | 14 | NSString *description = @""; 15 | 16 | @implementation SendingFileClient 17 | 18 | - (void)setview : (SendingViewController *) viewController{ 19 | self.mViewController = viewController; 20 | } 21 | 22 | 23 | -(void) initNetworkCommunication { 24 | CFWriteStreamRef writeStream; 25 | NSString *ip = @"192.168.49.1"; 26 | UInt32 sendPort = 8988; 27 | 28 | byteIndex = 0; 29 | CFStreamCreatePairWithSocketToHost(NULL, (__bridge CFStringRef)ip, sendPort, NULL , &writeStream); 30 | 31 | outputStream = (__bridge NSOutputStream *)writeStream; 32 | [outputStream setDelegate:self]; 33 | [outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; 34 | [outputStream open]; 35 | } 36 | 37 | 38 | - (void)stream:(NSStream *)theStream handleEvent:(NSStreamEvent)streamEvent 39 | { 40 | //NSLog(@"stream event %i", streamEvent); 41 | switch (streamEvent) { 42 | case NSStreamEventOpenCompleted: 43 | { 44 | NSLog(@"Stream opened!"); 45 | self.mViewController.result.text = @"Stream opened!"; 46 | isHeader = true; 47 | break; 48 | } 49 | case NSStreamEventHasBytesAvailable: 50 | { 51 | break; 52 | } 53 | case NSStreamEventErrorOccurred: 54 | { 55 | NSLog(@"Can not connect to the host!"); 56 | self.mViewController.result.text = @"Can not connect to the host!"; 57 | 58 | 59 | NSError *theError = [theStream streamError]; 60 | NSLog(@"Error: %@",theError); 61 | [theStream close]; 62 | 63 | UIAlertController *alertController = 64 | [UIAlertController alertControllerWithTitle:@"Send Fail" 65 | message:[theError description] 66 | preferredStyle:UIAlertControllerStyleAlert]; 67 | 68 | UIAlertAction *cancelAction =[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]; 69 | [alertController addAction:cancelAction]; 70 | [self.mViewController presentViewController:alertController animated:YES completion:nil]; 71 | break; 72 | } 73 | case NSStreamEventEndEncountered: 74 | { 75 | NSLog(@"NSStreamEventEndEncountered!"); 76 | self.mViewController.result.text = @"NSStreamEventEndEncountered!"; 77 | if(theStream == outputStream){ 78 | [outputStream close]; 79 | [outputStream removeFromRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; 80 | outputStream = nil; // stream is ivar, so reinit it 81 | } 82 | description = [NSString stringWithFormat:@"%@%@\n", description, self.mViewController.fileName.text]; 83 | 84 | NSUInteger mCount = [self.mViewController processImageList]; //To process others if exist 85 | NSLog(@"mCount: %tu",mCount); 86 | if(mCount == 0){ 87 | NSLog(@"Process finished"); 88 | UIAlertController *alertController = 89 | [UIAlertController alertControllerWithTitle:@"Sent File" 90 | message:description 91 | preferredStyle:UIAlertControllerStyleAlert]; 92 | 93 | 94 | UIAlertAction *okAction =[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleCancel handler:nil]; 95 | [alertController addAction:okAction]; 96 | description = @""; //reset 97 | [self.mViewController presentViewController:alertController animated:YES completion:nil]; 98 | } 99 | break; 100 | } 101 | case NSStreamEventHasSpaceAvailable: 102 | { 103 | if (theStream == outputStream){ 104 | //NSLog(@"NSStreamEventHasSpaceAvailable!"); 105 | self.mViewController.result.text = @"NSStreamEventHasSpaceAvailable!"; 106 | 107 | if(isHeader){ //everytime transfer packet header first, 1024 bytes for length + filename 108 | uint8_t headerBuf[1024]; 109 | NSUInteger headerLen = 1024; 110 | NSData* filename = [[self.mViewController.fileName text] dataUsingEncoding:NSUTF8StringEncoding]; 111 | uint8_t * filebytes = (uint8_t *)[filename bytes]; 112 | headerBuf[0] = filename.length; 113 | for (int i = 0 ; i < filename.length; i ++){ 114 | headerBuf[i+1] = filebytes[i]; 115 | } 116 | [outputStream write:(const uint8_t *)headerBuf maxLength:headerLen]; 117 | NSLog(@"outputStream write header %tu\n", headerLen); 118 | isHeader = false; 119 | } 120 | 121 | uint8_t *readBytes = (uint8_t *)[self.mViewController.imageData bytes]; 122 | readBytes += byteIndex; // instance variable to move pointer 123 | NSUInteger data_len = [self.mViewController.imageData length]; 124 | NSUInteger len = ((data_len - byteIndex >= 1024) ? 125 | 1024 : (data_len - byteIndex)); 126 | uint8_t buf[len]; 127 | (void)memcpy(buf, readBytes, len); 128 | len = [outputStream write:(const uint8_t *)buf maxLength:len]; 129 | //NSLog(@"outputStream write %ld\n", len); 130 | byteIndex += len; 131 | } 132 | break; 133 | } 134 | default: 135 | NSLog(@"Unknown event"); 136 | self.mViewController.result.text = @"Unknown event"; 137 | } 138 | 139 | } 140 | @end 141 | 142 | -------------------------------------------------------------------------------- /ImageTransfer/SendingViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // SendingViewController.h 3 | // ImageTransfer 4 | // 5 | // Created by LongHenry on 2016/3/15. 6 | // Copyright © 2016年 qisda. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "SendingFileClient.h" 11 | #import "ReceivingFileServer.h" 12 | 13 | @interface SendingViewController : UIViewController { 14 | NSUInteger byteIndex; 15 | SendingFileClient *mSendingClient; 16 | ReceivingFileServer *mReceivingFileServer; 17 | } 18 | 19 | /* 20 | * @Property是声明属性的语法,它可以快速方便的为实例变量创建存取器,并允许我们通过点语法使用存取器。 21 | */ 22 | @property (nonatomic, weak) IBOutlet UIImageView *imageView; 23 | @property (nonatomic, weak) IBOutlet UITextField *result; 24 | @property (nonatomic, weak) IBOutlet UITextField *fileName; 25 | @property (nonatomic, weak) IBOutlet UIButton *send; 26 | @property (nonatomic, strong) NSString *path; 27 | @property (nonatomic, strong) NSData *imageData; 28 | @property (nonatomic, strong) UIImagePickerController *imagePicker; 29 | 30 | @property (nonatomic, strong)NSMutableArray *imageArrayUrl; //from share extension 31 | @property (nonatomic, strong)NSMutableArray *imageArrayData; //from share extension 32 | 33 | - (NSUInteger) processImageList; 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /ImageTransfer/SendingViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // SendingViewController.m 3 | // ImageTransfer 4 | // 5 | // Created by LongHenry on 2016/3/15. 6 | // Copyright © 2016年 qisda. All rights reserved. 7 | // 8 | 9 | #import "SendingViewController.h" 10 | #import 11 | 12 | 13 | @implementation SendingViewController 14 | 15 | - (void)viewDidLoad 16 | { 17 | [super viewDidLoad]; 18 | 19 | NSString * path = [[NSBundle mainBundle] pathForResource: @"Qisda" ofType: @"jpg"]; //default picture 20 | NSURL * url = [NSURL fileURLWithPath: path]; 21 | self.fileName.text = [url lastPathComponent]; 22 | self.imageData = [NSData dataWithContentsOfURL:url]; //construct imageData 23 | 24 | //Initiate SendingClent 25 | mSendingClient = [[SendingFileClient alloc] init]; 26 | [mSendingClient setview: self]; 27 | 28 | //Initiate ReceivingFileServer 29 | mReceivingFileServer = [[ReceivingFileServer alloc] init]; 30 | [mReceivingFileServer setview: self]; 31 | [mReceivingFileServer setup]; 32 | } 33 | 34 | - (IBAction)dismissViewController:(id)sender 35 | { 36 | [self dismissViewControllerAnimated:YES completion:nil]; 37 | } 38 | 39 | - (IBAction)hideKeyboard:(UITextField *)sender 40 | { 41 | [sender resignFirstResponder]; 42 | } 43 | 44 | - (IBAction) sendAndroid:(id)sender{ 45 | [mSendingClient initNetworkCommunication]; 46 | } 47 | 48 | /* chose from gallery */ 49 | - (IBAction)chooseImage:(id)sender 50 | { 51 | [self presentViewController:self.imagePicker animated:YES completion:nil]; 52 | self.send.enabled = true; 53 | } 54 | 55 | - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info 56 | { 57 | [self.imagePicker dismissViewControllerAnimated:YES completion:nil]; 58 | self.imageView.image = [info objectForKey:UIImagePickerControllerOriginalImage];; 59 | self.imageData = UIImageJPEGRepresentation(self.imageView.image, 1.0); //we have raw data here 60 | //self.imageData = UIImagePNGRepresentation(self.imageView.image); 61 | 62 | ALAssetsLibrary *assetLibray = [[ALAssetsLibrary alloc] init]; 63 | [assetLibray assetForURL:[info objectForKey:UIImagePickerControllerReferenceURL] resultBlock:^(ALAsset *asset){ 64 | self.fileName.text = asset.defaultRepresentation.filename; //we have name here 65 | self.path = [asset.defaultRepresentation.url path]; //we have path here 66 | NSLog(@"image name is %@", self.fileName.text); 67 | NSLog(@"image path is %@", self.path); 68 | [mSendingClient initNetworkCommunication]; //send it directly 69 | } failureBlock:^(NSError *err){ 70 | NSLog(@"err:%@",err); 71 | }]; 72 | } 73 | 74 | #pragma mark - Getter 75 | - (UIImagePickerController *)imagePicker 76 | { 77 | if ( _imagePicker == nil ) 78 | { 79 | if ( [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum] ) 80 | { 81 | _imagePicker = [[UIImagePickerController alloc] init]; 82 | _imagePicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum; 83 | _imagePicker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeSavedPhotosAlbum]; 84 | _imagePicker.delegate = self; 85 | } 86 | } 87 | return _imagePicker; 88 | } 89 | 90 | 91 | - (NSUInteger) processImageList{ 92 | NSLog(@"imageArrayData count: %tu", self.imageArrayData.count); 93 | NSUInteger mCount = self.imageArrayData.count; 94 | if(self.imageArrayData.count != 0){ 95 | //deliver first index 96 | [self openImageURL: [NSURL fileURLWithPath: [self.imageArrayUrl objectAtIndex:0]]]; 97 | [self openImageData: [self.imageArrayData objectAtIndex:0]]; 98 | 99 | [mSendingClient initNetworkCommunication]; 100 | 101 | [self.imageArrayUrl removeObjectAtIndex:0]; 102 | [self.imageArrayData removeObjectAtIndex:0]; 103 | } 104 | return mCount; 105 | } 106 | 107 | - (void)openImageURL: (NSURL*)url 108 | { 109 | NSLog(@"openImageURL: %@",url); 110 | self.path = [url path]; //we have path here 111 | self.fileName.text = [url lastPathComponent]; 112 | } 113 | 114 | 115 | - (void)openImageData: (NSData*)image 116 | { 117 | NSLog(@"openImageData: %@",image); 118 | self.imageData = image; //construct imageData 119 | self.imageView.image = [[UIImage alloc] initWithData:image]; 120 | } 121 | 122 | @end 123 | -------------------------------------------------------------------------------- /ImageTransfer/SendingViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /ImageTransfer/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // ImageTransfer 4 | // 5 | // Created by LongHenry on 2016/3/15. 6 | // Copyright © 2016年 qisda. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ImageTransferExtension/ImageTransferExtension.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.application-groups 6 | 7 | group.ios.image.share 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /ImageTransferExtension/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ImageTransferExtension 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | XPC! 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleVersion 22 | 1 23 | NSExtension 24 | 25 | NSExtensionAttributes 26 | 27 | NSExtensionActivationRule 28 | 29 | NSExtensionActivationSupportsFileWithMaxCount 30 | 0 31 | NSExtensionActivationSupportsImageWithMaxCount 32 | 5 33 | NSExtensionActivationSupportsText 34 | 35 | NSExtensionActivationSupportsWebURLWithMaxCount 36 | 0 37 | 38 | 39 | NSExtensionPointIdentifier 40 | com.apple.share-services 41 | NSExtensionPrincipalClass 42 | ShareViewController 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /ImageTransferExtension/ShareViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ShareViewController.h 3 | // ImageTransferExtension 4 | // 5 | // Created by LongHenry on 2016/11/25. 6 | // Copyright © 2016年 qisda. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface ShareViewController : SLComposeServiceViewController { 13 | NSData *image; 14 | NSString *fileName; 15 | NSMutableArray *arrayOfImageUrl; 16 | NSMutableArray *arrayOfImageData; 17 | } 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /ImageTransferExtension/ShareViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ShareViewController.m 3 | // ImageTransferExtension 4 | // 5 | // Created by LongHenry on 2016/11/25. 6 | // Copyright © 2016年 qisda. All rights reserved. 7 | // 8 | 9 | #import "ShareViewController.h" 10 | #import 11 | 12 | @interface ShareViewController () 13 | 14 | @end 15 | 16 | 17 | @implementation ShareViewController 18 | 19 | - (void)loadView { 20 | [super loadView]; 21 | 22 | arrayOfImageUrl = [[NSMutableArray alloc] init]; 23 | arrayOfImageData = [[NSMutableArray alloc] init]; 24 | // Insert code here to customize the view 25 | self.title = NSLocalizedString(@"ImageShare", @"Title of the Social Service"); 26 | 27 | NSLog(@"Input Items = %@", self.extensionContext.inputItems); 28 | NSString *typeIdentifier = (NSString *)kUTTypeImage; //kUTTypeURL, kUTTypeImage; 29 | 30 | for (NSExtensionItem *item in self.extensionContext.inputItems){ 31 | for (NSItemProvider *itemProvider in item.attachments){ 32 | if ([itemProvider hasItemConformingToTypeIdentifier:typeIdentifier]) { 33 | [itemProvider loadItemForTypeIdentifier:typeIdentifier 34 | options:nil 35 | completionHandler:^(id item, NSError *error) { 36 | if(error){ 37 | NSLog(@"Error retrieving: %@", error); 38 | }else { 39 | if([(NSObject*)item isKindOfClass:[NSURL class]]) { 40 | NSURL* url = (NSURL*)item; 41 | fileName = [url lastPathComponent]; 42 | NSLog(@"fileName: %@",fileName); 43 | image = [NSData dataWithContentsOfURL:url]; 44 | [self inserDataToArray :[url path] : image]; 45 | } //end if([(NSObject*)item isKindOfClass:[NSURL class]]) 46 | } 47 | }]; 48 | } 49 | } 50 | } 51 | 52 | } 53 | 54 | - (void) viewDidLoad { 55 | NSLog(@"viewDidLoad"); 56 | [super viewDidLoad]; 57 | //[self.textView setEditable:false]; 58 | } 59 | 60 | - (void)didSelectPost { 61 | // Perform the post operation 62 | // When the operation is complete (probably asynchronously), the service should notify the success or failure as well as the items that were actually shared 63 | [self saveToExtension]; 64 | [self invokeApp:NULL]; 65 | [self.extensionContext completeRequestReturningItems:nil completionHandler:nil]; 66 | } 67 | 68 | /* 69 | * It'a a workaround because extensionContext openURL always fail 70 | */ 71 | - ( void ) invokeApp: ( NSString * ) invokeArgs 72 | { 73 | // Prepare the URL request 74 | // this will use the custom url scheme of your app 75 | // and the paths to the photos you want to share: 76 | NSLog(@"invokeApp"); 77 | NSString * urlString = [ NSString stringWithFormat: @"%@://%@", @"ImageShare", ( NULL == invokeArgs ? @"" : invokeArgs ) ]; 78 | NSURL * url = [ NSURL URLWithString: urlString ]; 79 | 80 | NSString *className = @"UIApplication"; 81 | if ( NSClassFromString( className ) ) 82 | { 83 | id object = [ NSClassFromString( className ) performSelector: @selector( sharedApplication ) ]; 84 | [ object performSelector: @selector( openURL: ) withObject: url ]; 85 | } 86 | 87 | // Now let the host app know we are done, so that it unblocks its UI: 88 | [ super didSelectPost ]; 89 | } 90 | 91 | 92 | - (void)didSelectCancel { 93 | // Cleanup 94 | // Notify the Service was cancelled 95 | NSError *cancelError = [NSError errorWithDomain:NSCocoaErrorDomain code:NSUserCancelledError userInfo:nil]; 96 | [self.extensionContext cancelRequestWithError:cancelError]; 97 | } 98 | 99 | 100 | - (BOOL)isContentValid { 101 | NSLog(@"isContentValid"); 102 | NSString * description =@""; 103 | NSString * extensions = @"jpg/jpeg/JPG/JPEG/png/PNG"; 104 | NSArray * types = [extensions pathComponents]; 105 | for (NSString *file in arrayOfImageUrl){ 106 | description = [NSString stringWithFormat:@"%@%@\n", description, [file lastPathComponent]]; 107 | BOOL isCorrectType = [types containsObject: [file pathExtension]]; 108 | if (!isCorrectType){ 109 | [self.textView setText:@"Format Not Allow! JPG/PNG Only"]; 110 | return NO; 111 | } 112 | } 113 | [self.textView setText:description]; 114 | return YES; 115 | } 116 | 117 | 118 | - (void)viewDidDisappear { 119 | NSLog(@"viewDidDisappear"); 120 | } 121 | 122 | - (void) inserDataToArray: (NSString*)fileUrl : (NSData*)imageData { 123 | [arrayOfImageUrl addObject:fileUrl]; 124 | [arrayOfImageData addObject:imageData]; 125 | } 126 | 127 | - (void)saveToExtension { 128 | NSLog(@"saveToExtension"); 129 | NSUserDefaults *shared = [[NSUserDefaults alloc] initWithSuiteName:@"group.ios.image.share"]; 130 | [shared setObject:arrayOfImageUrl forKey:@"url"]; 131 | [shared setObject:arrayOfImageData forKey:@"imageData"]; 132 | [shared synchronize]; 133 | } 134 | 135 | 136 | @end 137 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #ImageTransferiOS 2 | 3 | iOS(P2P legacy client) transfer JPEG image to Android Wifi Direct demo APP. 4 | Android device is GO, and iOS have to connect the GO via STA first. 5 | --------------------------------------------------------------------------------