├── .gitignore ├── LICENSE ├── Podfile ├── README.md ├── SwiftFlickrApp.xcodeproj └── project.pbxproj ├── SwiftFlickrApp ├── AppDelegate.swift ├── Base.lproj │ └── Main.storyboard ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── LaunchImage.launchimage │ │ └── Contents.json ├── Info.plist ├── PhotoCell.swift ├── PhotoViewController.swift ├── SwiftFlickrApp-Bridging-Header.h └── ViewController.swift ├── SwiftFlickrAppTests ├── Info.plist └── SwiftFlickrAppTests.swift └── Video.gif /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | .DS_Store 3 | */build/* 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | profile 14 | *.moved-aside 15 | DerivedData 16 | .idea/ 17 | *.hmap 18 | *.xccheckout 19 | 20 | *.xcworkspace 21 | !default.xcworkspace 22 | 23 | #CocoaPods 24 | Pods 25 | Podfile.lock 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Shu Shimbo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /Podfile: -------------------------------------------------------------------------------- 1 | platform :ios, '7.0' 2 | 3 | pod 'AFNetworking' 4 | pod 'SVProgressHUD' 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | SwiftFlickrApp 2 | ============== 3 | 4 | Flickr popular photo viewer with Swift 5 | * Swift iPhone application sample using UICollectionView and AFNetworking 6 | * More detail is here(Japanese): http://synboo.hatenablog.com/entry/2014/06/05/235618 7 | 8 | ## How to build 9 | 10 | 0. Install [CocoaPods](http://cocoapods.org/) and Xcode6 11 | 1. Clone this repository and move to project root directory 12 | 2. Execute `pod install` command at project root directory 13 | 3. Open .xcworkspace file 14 | 15 | ## Movie 16 | 17 | ![VideoGif](https://raw.githubusercontent.com/synboo/SwiftFlickrApp/master/Video.gif) 18 | 19 | ## Screenshot 20 | 21 | ![ScreenShot01](https://farm3.staticflickr.com/2903/14165768829_91b42f2047_b.jpg) 22 | ![ScreenShot02](https://farm4.staticflickr.com/3916/14351580334_d5488f512f_b.jpg) 23 | ![ScreenShot03](https://farm4.staticflickr.com/3871/14329316226_d9ff27471b_b.jpg) 24 | -------------------------------------------------------------------------------- /SwiftFlickrApp.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 03CDB234B397427A93F9E5EC /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = EDEF21E8C0B347D3B1D673DC /* libPods.a */; }; 11 | 596195311940AF480067C9C6 /* PhotoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 596195301940AF480067C9C6 /* PhotoViewController.swift */; }; 12 | 59CAF45F1940A3F8001250A5 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 59CAF45E1940A3F8001250A5 /* AppDelegate.swift */; }; 13 | 59CAF4611940A3F8001250A5 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 59CAF4601940A3F8001250A5 /* ViewController.swift */; }; 14 | 59CAF4641940A3F8001250A5 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 59CAF4621940A3F8001250A5 /* Main.storyboard */; }; 15 | 59CAF4661940A3F8001250A5 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 59CAF4651940A3F8001250A5 /* Images.xcassets */; }; 16 | 59CAF4721940A3F8001250A5 /* SwiftFlickrAppTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 59CAF4711940A3F8001250A5 /* SwiftFlickrAppTests.swift */; }; 17 | 59CAF4831940AA84001250A5 /* PhotoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 59CAF4821940AA84001250A5 /* PhotoCell.swift */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXContainerItemProxy section */ 21 | 59CAF46C1940A3F8001250A5 /* PBXContainerItemProxy */ = { 22 | isa = PBXContainerItemProxy; 23 | containerPortal = 59CAF4511940A3F8001250A5 /* Project object */; 24 | proxyType = 1; 25 | remoteGlobalIDString = 59CAF4581940A3F8001250A5; 26 | remoteInfo = SwiftFlickrApp; 27 | }; 28 | /* End PBXContainerItemProxy section */ 29 | 30 | /* Begin PBXFileReference section */ 31 | 596195301940AF480067C9C6 /* PhotoViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PhotoViewController.swift; sourceTree = ""; }; 32 | 59CAF4591940A3F8001250A5 /* SwiftFlickrApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftFlickrApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; 33 | 59CAF45D1940A3F8001250A5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 34 | 59CAF45E1940A3F8001250A5 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 35 | 59CAF4601940A3F8001250A5 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 36 | 59CAF4631940A3F8001250A5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 37 | 59CAF4651940A3F8001250A5 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 38 | 59CAF46B1940A3F8001250A5 /* SwiftFlickrAppTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwiftFlickrAppTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 39 | 59CAF4701940A3F8001250A5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 40 | 59CAF4711940A3F8001250A5 /* SwiftFlickrAppTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftFlickrAppTests.swift; sourceTree = ""; }; 41 | 59CAF47B1940A765001250A5 /* SwiftFlickrApp-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SwiftFlickrApp-Bridging-Header.h"; sourceTree = ""; }; 42 | 59CAF4821940AA84001250A5 /* PhotoCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PhotoCell.swift; sourceTree = ""; }; 43 | EDEF21E8C0B347D3B1D673DC /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; 44 | F9D80A7AF5A04EF1A7F281EE /* Pods.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.xcconfig; path = Pods/Pods.xcconfig; sourceTree = ""; }; 45 | /* End PBXFileReference section */ 46 | 47 | /* Begin PBXFrameworksBuildPhase section */ 48 | 59CAF4561940A3F8001250A5 /* Frameworks */ = { 49 | isa = PBXFrameworksBuildPhase; 50 | buildActionMask = 2147483647; 51 | files = ( 52 | 03CDB234B397427A93F9E5EC /* libPods.a in Frameworks */, 53 | ); 54 | runOnlyForDeploymentPostprocessing = 0; 55 | }; 56 | 59CAF4681940A3F8001250A5 /* Frameworks */ = { 57 | isa = PBXFrameworksBuildPhase; 58 | buildActionMask = 2147483647; 59 | files = ( 60 | ); 61 | runOnlyForDeploymentPostprocessing = 0; 62 | }; 63 | /* End PBXFrameworksBuildPhase section */ 64 | 65 | /* Begin PBXGroup section */ 66 | 59CAF4501940A3F8001250A5 = { 67 | isa = PBXGroup; 68 | children = ( 69 | 59CAF45B1940A3F8001250A5 /* SwiftFlickrApp */, 70 | 59CAF45C1940A3F8001250A5 /* Supporting Files */, 71 | 59CAF46E1940A3F8001250A5 /* SwiftFlickrAppTests */, 72 | 59CAF45A1940A3F8001250A5 /* Products */, 73 | F9D80A7AF5A04EF1A7F281EE /* Pods.xcconfig */, 74 | 8DFACCCE016E4485A1133E8D /* Frameworks */, 75 | ); 76 | sourceTree = ""; 77 | }; 78 | 59CAF45A1940A3F8001250A5 /* Products */ = { 79 | isa = PBXGroup; 80 | children = ( 81 | 59CAF4591940A3F8001250A5 /* SwiftFlickrApp.app */, 82 | 59CAF46B1940A3F8001250A5 /* SwiftFlickrAppTests.xctest */, 83 | ); 84 | name = Products; 85 | sourceTree = ""; 86 | }; 87 | 59CAF45B1940A3F8001250A5 /* SwiftFlickrApp */ = { 88 | isa = PBXGroup; 89 | children = ( 90 | 59CAF4621940A3F8001250A5 /* Main.storyboard */, 91 | 59CAF4651940A3F8001250A5 /* Images.xcassets */, 92 | 59CAF47B1940A765001250A5 /* SwiftFlickrApp-Bridging-Header.h */, 93 | 59CAF45E1940A3F8001250A5 /* AppDelegate.swift */, 94 | 59CAF4601940A3F8001250A5 /* ViewController.swift */, 95 | 59CAF4821940AA84001250A5 /* PhotoCell.swift */, 96 | 596195301940AF480067C9C6 /* PhotoViewController.swift */, 97 | ); 98 | path = SwiftFlickrApp; 99 | sourceTree = ""; 100 | }; 101 | 59CAF45C1940A3F8001250A5 /* Supporting Files */ = { 102 | isa = PBXGroup; 103 | children = ( 104 | 59CAF45D1940A3F8001250A5 /* Info.plist */, 105 | ); 106 | name = "Supporting Files"; 107 | path = SwiftFlickrApp; 108 | sourceTree = ""; 109 | }; 110 | 59CAF46E1940A3F8001250A5 /* SwiftFlickrAppTests */ = { 111 | isa = PBXGroup; 112 | children = ( 113 | 59CAF4711940A3F8001250A5 /* SwiftFlickrAppTests.swift */, 114 | 59CAF46F1940A3F8001250A5 /* Supporting Files */, 115 | ); 116 | path = SwiftFlickrAppTests; 117 | sourceTree = ""; 118 | }; 119 | 59CAF46F1940A3F8001250A5 /* Supporting Files */ = { 120 | isa = PBXGroup; 121 | children = ( 122 | 59CAF4701940A3F8001250A5 /* Info.plist */, 123 | ); 124 | name = "Supporting Files"; 125 | sourceTree = ""; 126 | }; 127 | 8DFACCCE016E4485A1133E8D /* Frameworks */ = { 128 | isa = PBXGroup; 129 | children = ( 130 | EDEF21E8C0B347D3B1D673DC /* libPods.a */, 131 | ); 132 | name = Frameworks; 133 | sourceTree = ""; 134 | }; 135 | /* End PBXGroup section */ 136 | 137 | /* Begin PBXNativeTarget section */ 138 | 59CAF4581940A3F8001250A5 /* SwiftFlickrApp */ = { 139 | isa = PBXNativeTarget; 140 | buildConfigurationList = 59CAF4751940A3F8001250A5 /* Build configuration list for PBXNativeTarget "SwiftFlickrApp" */; 141 | buildPhases = ( 142 | 5B4FD6C60E644E57BCE30E07 /* Check Pods Manifest.lock */, 143 | 59CAF4551940A3F8001250A5 /* Sources */, 144 | 59CAF4561940A3F8001250A5 /* Frameworks */, 145 | 59CAF4571940A3F8001250A5 /* Resources */, 146 | EE5828C79814426CAD2F1769 /* Copy Pods Resources */, 147 | ); 148 | buildRules = ( 149 | ); 150 | dependencies = ( 151 | ); 152 | name = SwiftFlickrApp; 153 | productName = SwiftFlickrApp; 154 | productReference = 59CAF4591940A3F8001250A5 /* SwiftFlickrApp.app */; 155 | productType = "com.apple.product-type.application"; 156 | }; 157 | 59CAF46A1940A3F8001250A5 /* SwiftFlickrAppTests */ = { 158 | isa = PBXNativeTarget; 159 | buildConfigurationList = 59CAF4781940A3F8001250A5 /* Build configuration list for PBXNativeTarget "SwiftFlickrAppTests" */; 160 | buildPhases = ( 161 | 59CAF4671940A3F8001250A5 /* Sources */, 162 | 59CAF4681940A3F8001250A5 /* Frameworks */, 163 | 59CAF4691940A3F8001250A5 /* Resources */, 164 | ); 165 | buildRules = ( 166 | ); 167 | dependencies = ( 168 | 59CAF46D1940A3F8001250A5 /* PBXTargetDependency */, 169 | ); 170 | name = SwiftFlickrAppTests; 171 | productName = SwiftFlickrAppTests; 172 | productReference = 59CAF46B1940A3F8001250A5 /* SwiftFlickrAppTests.xctest */; 173 | productType = "com.apple.product-type.bundle.unit-test"; 174 | }; 175 | /* End PBXNativeTarget section */ 176 | 177 | /* Begin PBXProject section */ 178 | 59CAF4511940A3F8001250A5 /* Project object */ = { 179 | isa = PBXProject; 180 | attributes = { 181 | LastUpgradeCheck = 0600; 182 | ORGANIZATIONNAME = synboo; 183 | TargetAttributes = { 184 | 59CAF4581940A3F8001250A5 = { 185 | CreatedOnToolsVersion = 6.0; 186 | }; 187 | 59CAF46A1940A3F8001250A5 = { 188 | CreatedOnToolsVersion = 6.0; 189 | TestTargetID = 59CAF4581940A3F8001250A5; 190 | }; 191 | }; 192 | }; 193 | buildConfigurationList = 59CAF4541940A3F8001250A5 /* Build configuration list for PBXProject "SwiftFlickrApp" */; 194 | compatibilityVersion = "Xcode 3.2"; 195 | developmentRegion = English; 196 | hasScannedForEncodings = 0; 197 | knownRegions = ( 198 | en, 199 | Base, 200 | ); 201 | mainGroup = 59CAF4501940A3F8001250A5; 202 | productRefGroup = 59CAF45A1940A3F8001250A5 /* Products */; 203 | projectDirPath = ""; 204 | projectRoot = ""; 205 | targets = ( 206 | 59CAF4581940A3F8001250A5 /* SwiftFlickrApp */, 207 | 59CAF46A1940A3F8001250A5 /* SwiftFlickrAppTests */, 208 | ); 209 | }; 210 | /* End PBXProject section */ 211 | 212 | /* Begin PBXResourcesBuildPhase section */ 213 | 59CAF4571940A3F8001250A5 /* Resources */ = { 214 | isa = PBXResourcesBuildPhase; 215 | buildActionMask = 2147483647; 216 | files = ( 217 | 59CAF4641940A3F8001250A5 /* Main.storyboard in Resources */, 218 | 59CAF4661940A3F8001250A5 /* Images.xcassets in Resources */, 219 | ); 220 | runOnlyForDeploymentPostprocessing = 0; 221 | }; 222 | 59CAF4691940A3F8001250A5 /* Resources */ = { 223 | isa = PBXResourcesBuildPhase; 224 | buildActionMask = 2147483647; 225 | files = ( 226 | ); 227 | runOnlyForDeploymentPostprocessing = 0; 228 | }; 229 | /* End PBXResourcesBuildPhase section */ 230 | 231 | /* Begin PBXShellScriptBuildPhase section */ 232 | 5B4FD6C60E644E57BCE30E07 /* Check Pods Manifest.lock */ = { 233 | isa = PBXShellScriptBuildPhase; 234 | buildActionMask = 2147483647; 235 | files = ( 236 | ); 237 | inputPaths = ( 238 | ); 239 | name = "Check Pods Manifest.lock"; 240 | outputPaths = ( 241 | ); 242 | runOnlyForDeploymentPostprocessing = 0; 243 | shellPath = /bin/sh; 244 | shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; 245 | showEnvVarsInLog = 0; 246 | }; 247 | EE5828C79814426CAD2F1769 /* Copy Pods Resources */ = { 248 | isa = PBXShellScriptBuildPhase; 249 | buildActionMask = 2147483647; 250 | files = ( 251 | ); 252 | inputPaths = ( 253 | ); 254 | name = "Copy Pods Resources"; 255 | outputPaths = ( 256 | ); 257 | runOnlyForDeploymentPostprocessing = 0; 258 | shellPath = /bin/sh; 259 | shellScript = "\"${SRCROOT}/Pods/Pods-resources.sh\"\n"; 260 | showEnvVarsInLog = 0; 261 | }; 262 | /* End PBXShellScriptBuildPhase section */ 263 | 264 | /* Begin PBXSourcesBuildPhase section */ 265 | 59CAF4551940A3F8001250A5 /* Sources */ = { 266 | isa = PBXSourcesBuildPhase; 267 | buildActionMask = 2147483647; 268 | files = ( 269 | 59CAF4611940A3F8001250A5 /* ViewController.swift in Sources */, 270 | 596195311940AF480067C9C6 /* PhotoViewController.swift in Sources */, 271 | 59CAF4831940AA84001250A5 /* PhotoCell.swift in Sources */, 272 | 59CAF45F1940A3F8001250A5 /* AppDelegate.swift in Sources */, 273 | ); 274 | runOnlyForDeploymentPostprocessing = 0; 275 | }; 276 | 59CAF4671940A3F8001250A5 /* Sources */ = { 277 | isa = PBXSourcesBuildPhase; 278 | buildActionMask = 2147483647; 279 | files = ( 280 | 59CAF4721940A3F8001250A5 /* SwiftFlickrAppTests.swift in Sources */, 281 | ); 282 | runOnlyForDeploymentPostprocessing = 0; 283 | }; 284 | /* End PBXSourcesBuildPhase section */ 285 | 286 | /* Begin PBXTargetDependency section */ 287 | 59CAF46D1940A3F8001250A5 /* PBXTargetDependency */ = { 288 | isa = PBXTargetDependency; 289 | target = 59CAF4581940A3F8001250A5 /* SwiftFlickrApp */; 290 | targetProxy = 59CAF46C1940A3F8001250A5 /* PBXContainerItemProxy */; 291 | }; 292 | /* End PBXTargetDependency section */ 293 | 294 | /* Begin PBXVariantGroup section */ 295 | 59CAF4621940A3F8001250A5 /* Main.storyboard */ = { 296 | isa = PBXVariantGroup; 297 | children = ( 298 | 59CAF4631940A3F8001250A5 /* Base */, 299 | ); 300 | name = Main.storyboard; 301 | sourceTree = ""; 302 | }; 303 | /* End PBXVariantGroup section */ 304 | 305 | /* Begin XCBuildConfiguration section */ 306 | 59CAF4731940A3F8001250A5 /* Debug */ = { 307 | isa = XCBuildConfiguration; 308 | buildSettings = { 309 | ALWAYS_SEARCH_USER_PATHS = NO; 310 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 311 | CLANG_CXX_LIBRARY = "libc++"; 312 | CLANG_ENABLE_MODULES = YES; 313 | CLANG_ENABLE_OBJC_ARC = YES; 314 | CLANG_WARN_BOOL_CONVERSION = YES; 315 | CLANG_WARN_CONSTANT_CONVERSION = YES; 316 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 317 | CLANG_WARN_EMPTY_BODY = YES; 318 | CLANG_WARN_ENUM_CONVERSION = YES; 319 | CLANG_WARN_INT_CONVERSION = YES; 320 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 321 | CLANG_WARN_UNREACHABLE_CODE = YES; 322 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 323 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 324 | COPY_PHASE_STRIP = NO; 325 | ENABLE_STRICT_OBJC_MSGSEND = YES; 326 | GCC_C_LANGUAGE_STANDARD = gnu99; 327 | GCC_DYNAMIC_NO_PIC = NO; 328 | GCC_OPTIMIZATION_LEVEL = 0; 329 | GCC_PREPROCESSOR_DEFINITIONS = ( 330 | "DEBUG=1", 331 | "$(inherited)", 332 | ); 333 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 334 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 335 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 336 | GCC_WARN_UNDECLARED_SELECTOR = YES; 337 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 338 | GCC_WARN_UNUSED_FUNCTION = YES; 339 | GCC_WARN_UNUSED_VARIABLE = YES; 340 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 341 | METAL_ENABLE_DEBUG_INFO = YES; 342 | ONLY_ACTIVE_ARCH = YES; 343 | SDKROOT = iphoneos; 344 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 345 | }; 346 | name = Debug; 347 | }; 348 | 59CAF4741940A3F8001250A5 /* Release */ = { 349 | isa = XCBuildConfiguration; 350 | buildSettings = { 351 | ALWAYS_SEARCH_USER_PATHS = NO; 352 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 353 | CLANG_CXX_LIBRARY = "libc++"; 354 | CLANG_ENABLE_MODULES = YES; 355 | CLANG_ENABLE_OBJC_ARC = YES; 356 | CLANG_WARN_BOOL_CONVERSION = YES; 357 | CLANG_WARN_CONSTANT_CONVERSION = YES; 358 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 359 | CLANG_WARN_EMPTY_BODY = YES; 360 | CLANG_WARN_ENUM_CONVERSION = YES; 361 | CLANG_WARN_INT_CONVERSION = YES; 362 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 363 | CLANG_WARN_UNREACHABLE_CODE = YES; 364 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 365 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 366 | COPY_PHASE_STRIP = YES; 367 | ENABLE_NS_ASSERTIONS = NO; 368 | ENABLE_STRICT_OBJC_MSGSEND = YES; 369 | GCC_C_LANGUAGE_STANDARD = gnu99; 370 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 371 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 372 | GCC_WARN_UNDECLARED_SELECTOR = YES; 373 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 374 | GCC_WARN_UNUSED_FUNCTION = YES; 375 | GCC_WARN_UNUSED_VARIABLE = YES; 376 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 377 | METAL_ENABLE_DEBUG_INFO = NO; 378 | SDKROOT = iphoneos; 379 | VALIDATE_PRODUCT = YES; 380 | }; 381 | name = Release; 382 | }; 383 | 59CAF4761940A3F8001250A5 /* Debug */ = { 384 | isa = XCBuildConfiguration; 385 | baseConfigurationReference = F9D80A7AF5A04EF1A7F281EE /* Pods.xcconfig */; 386 | buildSettings = { 387 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 388 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 389 | CLANG_ENABLE_MODULES = YES; 390 | INFOPLIST_FILE = SwiftFlickrApp/Info.plist; 391 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 392 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 393 | PRODUCT_NAME = "$(TARGET_NAME)"; 394 | SWIFT_OBJC_BRIDGING_HEADER = "SwiftFlickrApp/SwiftFlickrApp-Bridging-Header.h"; 395 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 396 | }; 397 | name = Debug; 398 | }; 399 | 59CAF4771940A3F8001250A5 /* Release */ = { 400 | isa = XCBuildConfiguration; 401 | baseConfigurationReference = F9D80A7AF5A04EF1A7F281EE /* Pods.xcconfig */; 402 | buildSettings = { 403 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 404 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 405 | CLANG_ENABLE_MODULES = YES; 406 | INFOPLIST_FILE = SwiftFlickrApp/Info.plist; 407 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 408 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 409 | PRODUCT_NAME = "$(TARGET_NAME)"; 410 | SWIFT_OBJC_BRIDGING_HEADER = "SwiftFlickrApp/SwiftFlickrApp-Bridging-Header.h"; 411 | }; 412 | name = Release; 413 | }; 414 | 59CAF4791940A3F8001250A5 /* Debug */ = { 415 | isa = XCBuildConfiguration; 416 | buildSettings = { 417 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/SwiftFlickrApp.app/SwiftFlickrApp"; 418 | FRAMEWORK_SEARCH_PATHS = ( 419 | "$(SDKROOT)/Developer/Library/Frameworks", 420 | "$(inherited)", 421 | ); 422 | GCC_PREPROCESSOR_DEFINITIONS = ( 423 | "DEBUG=1", 424 | "$(inherited)", 425 | ); 426 | INFOPLIST_FILE = SwiftFlickrAppTests/Info.plist; 427 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 428 | METAL_ENABLE_DEBUG_INFO = YES; 429 | PRODUCT_NAME = "$(TARGET_NAME)"; 430 | TEST_HOST = "$(BUNDLE_LOADER)"; 431 | }; 432 | name = Debug; 433 | }; 434 | 59CAF47A1940A3F8001250A5 /* Release */ = { 435 | isa = XCBuildConfiguration; 436 | buildSettings = { 437 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/SwiftFlickrApp.app/SwiftFlickrApp"; 438 | FRAMEWORK_SEARCH_PATHS = ( 439 | "$(SDKROOT)/Developer/Library/Frameworks", 440 | "$(inherited)", 441 | ); 442 | INFOPLIST_FILE = SwiftFlickrAppTests/Info.plist; 443 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 444 | METAL_ENABLE_DEBUG_INFO = NO; 445 | PRODUCT_NAME = "$(TARGET_NAME)"; 446 | TEST_HOST = "$(BUNDLE_LOADER)"; 447 | }; 448 | name = Release; 449 | }; 450 | /* End XCBuildConfiguration section */ 451 | 452 | /* Begin XCConfigurationList section */ 453 | 59CAF4541940A3F8001250A5 /* Build configuration list for PBXProject "SwiftFlickrApp" */ = { 454 | isa = XCConfigurationList; 455 | buildConfigurations = ( 456 | 59CAF4731940A3F8001250A5 /* Debug */, 457 | 59CAF4741940A3F8001250A5 /* Release */, 458 | ); 459 | defaultConfigurationIsVisible = 0; 460 | defaultConfigurationName = Release; 461 | }; 462 | 59CAF4751940A3F8001250A5 /* Build configuration list for PBXNativeTarget "SwiftFlickrApp" */ = { 463 | isa = XCConfigurationList; 464 | buildConfigurations = ( 465 | 59CAF4761940A3F8001250A5 /* Debug */, 466 | 59CAF4771940A3F8001250A5 /* Release */, 467 | ); 468 | defaultConfigurationIsVisible = 0; 469 | defaultConfigurationName = Release; 470 | }; 471 | 59CAF4781940A3F8001250A5 /* Build configuration list for PBXNativeTarget "SwiftFlickrAppTests" */ = { 472 | isa = XCConfigurationList; 473 | buildConfigurations = ( 474 | 59CAF4791940A3F8001250A5 /* Debug */, 475 | 59CAF47A1940A3F8001250A5 /* Release */, 476 | ); 477 | defaultConfigurationIsVisible = 0; 478 | defaultConfigurationName = Release; 479 | }; 480 | /* End XCConfigurationList section */ 481 | }; 482 | rootObject = 59CAF4511940A3F8001250A5 /* Project object */; 483 | } 484 | -------------------------------------------------------------------------------- /SwiftFlickrApp/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // SwiftFlickrApp 4 | // 5 | // Created by synboo on 6/5/14. 6 | // Copyright (c) 2014 synboo. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | 13 | class AppDelegate: UIResponder, UIApplicationDelegate 14 | { 15 | 16 | var window: UIWindow? 17 | 18 | func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool 19 | { 20 | return true 21 | } 22 | 23 | } 24 | 25 | -------------------------------------------------------------------------------- /SwiftFlickrApp/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 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 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | -------------------------------------------------------------------------------- /SwiftFlickrApp/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "40x40", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "60x60", 16 | "scale" : "2x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /SwiftFlickrApp/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "7.0", 8 | "scale" : "2x" 9 | }, 10 | { 11 | "orientation" : "portrait", 12 | "idiom" : "iphone", 13 | "subtype" : "retina4", 14 | "extent" : "full-screen", 15 | "minimum-system-version" : "7.0", 16 | "scale" : "2x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /SwiftFlickrApp/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.synboo.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UIStatusBarHidden 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | 37 | UIViewControllerBasedStatusBarAppearance 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /SwiftFlickrApp/PhotoCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PhotoCell.swift 3 | // SwiftFlickrApp 4 | // 5 | // Created by synboo on 6/5/14. 6 | // Copyright (c) 2014 synboo. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class PhotoCell: UICollectionViewCell 12 | { 13 | @IBOutlet var photoImageView : UIImageView 14 | var photoInfo : Dictionary? 15 | 16 | // init(coder aDecoder: NSCoder!) 17 | // { 18 | // super.init(coder: aDecoder) 19 | // } 20 | 21 | override func prepareForReuse() 22 | { 23 | super.prepareForReuse() 24 | self.photoImageView.image = nil 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /SwiftFlickrApp/PhotoViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PhotoViewController.swift 3 | // SwiftFlickrApp 4 | // 5 | // Created by synboo on 6/5/14. 6 | // Copyright (c) 2014 synboo. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class PhotoViewController: UIViewController { 12 | 13 | var photoInfo : Dictionary! 14 | @IBOutlet var photoImageView : UIImageView 15 | 16 | init(coder aDecoder: NSCoder!) 17 | { 18 | super.init(coder: aDecoder) 19 | self.photoInfo = ["title" : ""] 20 | } 21 | 22 | override func viewDidLoad() 23 | { 24 | super.viewDidLoad() 25 | self.title = self.photoInfo["title"] 26 | self.photoImageView.setImageWithURL(NSURL.URLWithString(self.photoInfo["url_z"])) 27 | } 28 | 29 | override func didReceiveMemoryWarning() 30 | { 31 | super.didReceiveMemoryWarning() 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /SwiftFlickrApp/SwiftFlickrApp-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | 5 | #import "AFNetworking.h" 6 | #import "UIImageView+AFNetworking.h" 7 | #import "SVProgressHUD.h" -------------------------------------------------------------------------------- /SwiftFlickrApp/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // SwiftFlickrApp 4 | // 5 | // Created by synboo on 6/5/14. 6 | // Copyright (c) 2014 synboo. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | enum LayoutType: Int 12 | { 13 | case Grid = 0 14 | case List = 1 15 | } 16 | 17 | class ViewController: UICollectionViewController 18 | { 19 | var photos:Dictionary[] = [] 20 | var layoutType = LayoutType.Grid 21 | 22 | override func viewDidLoad() 23 | { 24 | super.viewDidLoad() 25 | getFlickrPhotos() 26 | } 27 | 28 | override func didReceiveMemoryWarning() 29 | { 30 | super.didReceiveMemoryWarning() 31 | } 32 | 33 | func getFlickrPhotos() 34 | { 35 | let manager :AFHTTPRequestOperationManager = AFHTTPRequestOperationManager() 36 | let url :String = "https://api.flickr.com/services/rest/" 37 | let parameters :Dictionary = [ 38 | "method" : "flickr.interestingness.getList", 39 | "api_key" : "86997f23273f5a518b027e2c8c019b0f", 40 | "per_page" : "99", 41 | "format" : "json", 42 | "nojsoncallback" : "1", 43 | "extras" : "url_q,url_z", 44 | ] 45 | let requestSuccess = { 46 | (operation :AFHTTPRequestOperation!, responseObject :AnyObject!) -> Void in 47 | SVProgressHUD.dismiss() 48 | self.photos = responseObject.objectForKey("photos").objectForKey("photo") as Array 49 | self.collectionView.reloadData() 50 | NSLog("requestSuccess \(responseObject)") 51 | } 52 | let requestFailure = { 53 | (operation :AFHTTPRequestOperation!, error :NSError!) -> Void in 54 | SVProgressHUD.dismiss() 55 | NSLog("requestFailure: \(error)") 56 | } 57 | SVProgressHUD.show() 58 | manager.GET(url, parameters: parameters, success: requestSuccess, failure: requestFailure) 59 | } 60 | 61 | // MARK: - UICollectionView 62 | 63 | override func collectionView(collectionView: UICollectionView!, numberOfItemsInSection section: Int) -> Int 64 | { 65 | return self.photos.count; 66 | } 67 | 68 | override func collectionView(collectionView: UICollectionView!, cellForItemAtIndexPath indexPath: NSIndexPath!) -> UICollectionViewCell! 69 | { 70 | let photoCell: PhotoCell = self.collectionView.dequeueReusableCellWithReuseIdentifier("PhotoCell", forIndexPath: indexPath) as PhotoCell 71 | let photoInfo = photos[indexPath.item] as Dictionary 72 | let photoUrlString = (self.layoutType == LayoutType.Grid) ? photoInfo["url_q"] : photoInfo["url_z"] 73 | let photoUrlRequest : NSURLRequest = NSURLRequest(URL: NSURL.URLWithString(photoUrlString)) 74 | 75 | let imageRequestSuccess = { 76 | (request : NSURLRequest!, response : NSHTTPURLResponse!, image : UIImage!) -> Void in 77 | photoCell.photoImageView.image = image; 78 | photoCell.photoImageView.alpha = 0 79 | UIView.animateWithDuration(0.2, animations: { 80 | photoCell.photoImageView.alpha = 1.0 81 | }) 82 | } 83 | let imageRequestFailure = { 84 | (request : NSURLRequest!, response : NSHTTPURLResponse!, error : NSError!) -> Void in 85 | NSLog("imageRequrestFailure") 86 | } 87 | photoCell.photoImageView.setImageWithURLRequest(photoUrlRequest, placeholderImage: nil, success: imageRequestSuccess, failure: imageRequestFailure) 88 | 89 | photoCell.photoInfo = photoInfo 90 | return photoCell; 91 | } 92 | 93 | func collectionView(collectionView: UICollectionView!, layout collectionViewLayout: UICollectionViewLayout!, sizeForItemAtIndexPath indexPath: NSIndexPath!) -> CGSize 94 | { 95 | var itemSize : CGSize 96 | if self.layoutType == LayoutType.Grid 97 | { 98 | itemSize = (indexPath.item%3 == 1) ? CGSizeMake(106, 106) : CGSizeMake(107, 106) 99 | } 100 | else 101 | { 102 | itemSize = CGSizeMake(320, 150) 103 | } 104 | return itemSize 105 | } 106 | 107 | @IBAction func segmentedControlDidChanged(control : UISegmentedControl) 108 | { 109 | switch control.selectedSegmentIndex { 110 | case 0: 111 | self.layoutType = LayoutType.Grid 112 | case 1: 113 | self.layoutType = LayoutType.List 114 | default: 115 | self.layoutType = LayoutType.Grid 116 | } 117 | 118 | self.collectionView.reloadData() 119 | } 120 | 121 | override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!) 122 | { 123 | if segue.identifier == "ShowPhoto" 124 | { 125 | let photoCell : PhotoCell = sender as PhotoCell 126 | var photoViewController = segue.destinationViewController as PhotoViewController 127 | photoViewController.photoInfo = photoCell.photoInfo 128 | } 129 | } 130 | } 131 | 132 | -------------------------------------------------------------------------------- /SwiftFlickrAppTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.synboo.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /SwiftFlickrAppTests/SwiftFlickrAppTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftFlickrAppTests.swift 3 | // SwiftFlickrAppTests 4 | // 5 | // Created by synboo on 6/5/14. 6 | // Copyright (c) 2014 synboo. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class SwiftFlickrAppTests: XCTestCase { 12 | 13 | override func setUp() { 14 | super.setUp() 15 | // Put setup code here. This method is called before the invocation of each test method in the class. 16 | } 17 | 18 | override func tearDown() { 19 | // Put teardown code here. This method is called after the invocation of each test method in the class. 20 | super.tearDown() 21 | } 22 | 23 | func testExample() { 24 | // This is an example of a functional test case. 25 | XCTAssert(true, "Pass") 26 | } 27 | 28 | func testPerformanceExample() { 29 | // This is an example of a performance test case. 30 | self.measureBlock() { 31 | // Put the code you want to measure the time of here. 32 | } 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /Video.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/synboo/SwiftFlickrApp/556ab6634057ea4f7b27fab48c4821860addc027/Video.gif --------------------------------------------------------------------------------