From 4f19d6f7aaf017871e8db82dd28f9bb5170175a5 Mon Sep 17 00:00:00 2001 From: Jameson Quave Date: Mon, 2 Jun 2014 15:31:16 -0500 Subject: [PATCH 01/19] Initial Commit --- TestSwift.xcodeproj/project.pbxproj | 414 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + TestSwift/AppDelegate.swift | 46 ++ TestSwift/Base.lproj/Main.storyboard | 25 ++ .../AppIcon.appiconset/Contents.json | 53 +++ .../LaunchImage.launchimage/Contents.json | 51 +++ TestSwift/Info.plist | 32 ++ TestSwift/ViewController.swift | 25 ++ TestSwiftTests/Info.plist | 24 + TestSwiftTests/TestSwiftTests.swift | 35 ++ 10 files changed, 712 insertions(+) create mode 100644 TestSwift.xcodeproj/project.pbxproj create mode 100644 TestSwift.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 TestSwift/AppDelegate.swift create mode 100644 TestSwift/Base.lproj/Main.storyboard create mode 100644 TestSwift/Images.xcassets/AppIcon.appiconset/Contents.json create mode 100644 TestSwift/Images.xcassets/LaunchImage.launchimage/Contents.json create mode 100644 TestSwift/Info.plist create mode 100644 TestSwift/ViewController.swift create mode 100644 TestSwiftTests/Info.plist create mode 100644 TestSwiftTests/TestSwiftTests.swift diff --git a/TestSwift.xcodeproj/project.pbxproj b/TestSwift.xcodeproj/project.pbxproj new file mode 100644 index 0000000..cc4b4a9 --- /dev/null +++ b/TestSwift.xcodeproj/project.pbxproj @@ -0,0 +1,414 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 02CCF4A8193D16930069AEE9 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02CCF4A7193D16930069AEE9 /* AppDelegate.swift */; }; + 02CCF4AA193D16930069AEE9 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02CCF4A9193D16930069AEE9 /* ViewController.swift */; }; + 02CCF4AD193D16930069AEE9 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 02CCF4AB193D16930069AEE9 /* Main.storyboard */; }; + 02CCF4AF193D16930069AEE9 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 02CCF4AE193D16930069AEE9 /* Images.xcassets */; }; + 02CCF4BB193D16930069AEE9 /* TestSwiftTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02CCF4BA193D16930069AEE9 /* TestSwiftTests.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 02CCF4B5193D16930069AEE9 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 02CCF49A193D16930069AEE9 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 02CCF4A1193D16930069AEE9; + remoteInfo = TestSwift; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 02CCF4A2193D16930069AEE9 /* TestSwift.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TestSwift.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 02CCF4A6193D16930069AEE9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 02CCF4A7193D16930069AEE9 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 02CCF4A9193D16930069AEE9 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + 02CCF4AC193D16930069AEE9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 02CCF4AE193D16930069AEE9 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; + 02CCF4B4193D16930069AEE9 /* TestSwiftTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TestSwiftTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 02CCF4B9193D16930069AEE9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 02CCF4BA193D16930069AEE9 /* TestSwiftTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestSwiftTests.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 02CCF49F193D16930069AEE9 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 02CCF4B1193D16930069AEE9 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 02CCF499193D16930069AEE9 = { + isa = PBXGroup; + children = ( + 02CCF4A4193D16930069AEE9 /* TestSwift */, + 02CCF4B7193D16930069AEE9 /* TestSwiftTests */, + 02CCF4A3193D16930069AEE9 /* Products */, + ); + sourceTree = ""; + }; + 02CCF4A3193D16930069AEE9 /* Products */ = { + isa = PBXGroup; + children = ( + 02CCF4A2193D16930069AEE9 /* TestSwift.app */, + 02CCF4B4193D16930069AEE9 /* TestSwiftTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 02CCF4A4193D16930069AEE9 /* TestSwift */ = { + isa = PBXGroup; + children = ( + 02CCF4A7193D16930069AEE9 /* AppDelegate.swift */, + 02CCF4A9193D16930069AEE9 /* ViewController.swift */, + 02CCF4AB193D16930069AEE9 /* Main.storyboard */, + 02CCF4AE193D16930069AEE9 /* Images.xcassets */, + 02CCF4A5193D16930069AEE9 /* Supporting Files */, + ); + path = TestSwift; + sourceTree = ""; + }; + 02CCF4A5193D16930069AEE9 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 02CCF4A6193D16930069AEE9 /* Info.plist */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 02CCF4B7193D16930069AEE9 /* TestSwiftTests */ = { + isa = PBXGroup; + children = ( + 02CCF4BA193D16930069AEE9 /* TestSwiftTests.swift */, + 02CCF4B8193D16930069AEE9 /* Supporting Files */, + ); + path = TestSwiftTests; + sourceTree = ""; + }; + 02CCF4B8193D16930069AEE9 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 02CCF4B9193D16930069AEE9 /* Info.plist */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 02CCF4A1193D16930069AEE9 /* TestSwift */ = { + isa = PBXNativeTarget; + buildConfigurationList = 02CCF4BE193D16930069AEE9 /* Build configuration list for PBXNativeTarget "TestSwift" */; + buildPhases = ( + 02CCF49E193D16930069AEE9 /* Sources */, + 02CCF49F193D16930069AEE9 /* Frameworks */, + 02CCF4A0193D16930069AEE9 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = TestSwift; + productName = TestSwift; + productReference = 02CCF4A2193D16930069AEE9 /* TestSwift.app */; + productType = "com.apple.product-type.application"; + }; + 02CCF4B3193D16930069AEE9 /* TestSwiftTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 02CCF4C1193D16930069AEE9 /* Build configuration list for PBXNativeTarget "TestSwiftTests" */; + buildPhases = ( + 02CCF4B0193D16930069AEE9 /* Sources */, + 02CCF4B1193D16930069AEE9 /* Frameworks */, + 02CCF4B2193D16930069AEE9 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 02CCF4B6193D16930069AEE9 /* PBXTargetDependency */, + ); + name = TestSwiftTests; + productName = TestSwiftTests; + productReference = 02CCF4B4193D16930069AEE9 /* TestSwiftTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 02CCF49A193D16930069AEE9 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0600; + ORGANIZATIONNAME = "JQ Software LLC"; + TargetAttributes = { + 02CCF4A1193D16930069AEE9 = { + CreatedOnToolsVersion = 6.0; + }; + 02CCF4B3193D16930069AEE9 = { + CreatedOnToolsVersion = 6.0; + TestTargetID = 02CCF4A1193D16930069AEE9; + }; + }; + }; + buildConfigurationList = 02CCF49D193D16930069AEE9 /* Build configuration list for PBXProject "TestSwift" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 02CCF499193D16930069AEE9; + productRefGroup = 02CCF4A3193D16930069AEE9 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 02CCF4A1193D16930069AEE9 /* TestSwift */, + 02CCF4B3193D16930069AEE9 /* TestSwiftTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 02CCF4A0193D16930069AEE9 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 02CCF4AD193D16930069AEE9 /* Main.storyboard in Resources */, + 02CCF4AF193D16930069AEE9 /* Images.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 02CCF4B2193D16930069AEE9 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 02CCF49E193D16930069AEE9 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 02CCF4AA193D16930069AEE9 /* ViewController.swift in Sources */, + 02CCF4A8193D16930069AEE9 /* AppDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 02CCF4B0193D16930069AEE9 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 02CCF4BB193D16930069AEE9 /* TestSwiftTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 02CCF4B6193D16930069AEE9 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 02CCF4A1193D16930069AEE9 /* TestSwift */; + targetProxy = 02CCF4B5193D16930069AEE9 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 02CCF4AB193D16930069AEE9 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 02CCF4AC193D16930069AEE9 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 02CCF4BC193D16930069AEE9 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + METAL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 02CCF4BD193D16930069AEE9 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = YES; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + METAL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 02CCF4BF193D16930069AEE9 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + INFOPLIST_FILE = TestSwift/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 02CCF4C0193D16930069AEE9 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + INFOPLIST_FILE = TestSwift/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; + 02CCF4C2193D16930069AEE9 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/TestSwift.app/TestSwift"; + FRAMEWORK_SEARCH_PATHS = ( + "$(SDKROOT)/Developer/Library/Frameworks", + "$(inherited)", + ); + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + INFOPLIST_FILE = TestSwiftTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + METAL_ENABLE_DEBUG_INFO = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUNDLE_LOADER)"; + }; + name = Debug; + }; + 02CCF4C3193D16930069AEE9 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/TestSwift.app/TestSwift"; + FRAMEWORK_SEARCH_PATHS = ( + "$(SDKROOT)/Developer/Library/Frameworks", + "$(inherited)", + ); + INFOPLIST_FILE = TestSwiftTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + METAL_ENABLE_DEBUG_INFO = NO; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUNDLE_LOADER)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 02CCF49D193D16930069AEE9 /* Build configuration list for PBXProject "TestSwift" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 02CCF4BC193D16930069AEE9 /* Debug */, + 02CCF4BD193D16930069AEE9 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 02CCF4BE193D16930069AEE9 /* Build configuration list for PBXNativeTarget "TestSwift" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 02CCF4BF193D16930069AEE9 /* Debug */, + 02CCF4C0193D16930069AEE9 /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; + 02CCF4C1193D16930069AEE9 /* Build configuration list for PBXNativeTarget "TestSwiftTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 02CCF4C2193D16930069AEE9 /* Debug */, + 02CCF4C3193D16930069AEE9 /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; +/* End XCConfigurationList section */ + }; + rootObject = 02CCF49A193D16930069AEE9 /* Project object */; +} diff --git a/TestSwift.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/TestSwift.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..06aa6b4 --- /dev/null +++ b/TestSwift.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/TestSwift/AppDelegate.swift b/TestSwift/AppDelegate.swift new file mode 100644 index 0000000..ff3b3ec --- /dev/null +++ b/TestSwift/AppDelegate.swift @@ -0,0 +1,46 @@ +// +// AppDelegate.swift +// TestSwift +// +// Created by Jameson Quave on 6/2/14. +// Copyright (c) 2014 JQ Software LLC. All rights reserved. +// + +import UIKit + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + + var window: UIWindow? + + + func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool { + // Override point for customization after application launch. + return true + } + + func applicationWillResignActive(application: UIApplication) { + // 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. + // 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. + } + + func applicationDidEnterBackground(application: UIApplication) { + // 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. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. + } + + func applicationWillEnterForeground(application: UIApplication) { + // 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. + } + + func applicationDidBecomeActive(application: UIApplication) { + // 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. + } + + func applicationWillTerminate(application: UIApplication) { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. + } + + +} + diff --git a/TestSwift/Base.lproj/Main.storyboard b/TestSwift/Base.lproj/Main.storyboard new file mode 100644 index 0000000..5ee93c5 --- /dev/null +++ b/TestSwift/Base.lproj/Main.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/TestSwift/Images.xcassets/AppIcon.appiconset/Contents.json b/TestSwift/Images.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..91bf9c1 --- /dev/null +++ b/TestSwift/Images.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,53 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/TestSwift/Images.xcassets/LaunchImage.launchimage/Contents.json b/TestSwift/Images.xcassets/LaunchImage.launchimage/Contents.json new file mode 100644 index 0000000..6f870a4 --- /dev/null +++ b/TestSwift/Images.xcassets/LaunchImage.launchimage/Contents.json @@ -0,0 +1,51 @@ +{ + "images" : [ + { + "orientation" : "portrait", + "idiom" : "iphone", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "2x" + }, + { + "orientation" : "portrait", + "idiom" : "iphone", + "subtype" : "retina4", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "2x" + }, + { + "orientation" : "portrait", + "idiom" : "ipad", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "1x" + }, + { + "orientation" : "landscape", + "idiom" : "ipad", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "1x" + }, + { + "orientation" : "portrait", + "idiom" : "ipad", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "2x" + }, + { + "orientation" : "landscape", + "idiom" : "ipad", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/TestSwift/Info.plist b/TestSwift/Info.plist new file mode 100644 index 0000000..310bb7e --- /dev/null +++ b/TestSwift/Info.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + com.jqsoftware.${PRODUCT_NAME:rfc1034identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + + diff --git a/TestSwift/ViewController.swift b/TestSwift/ViewController.swift new file mode 100644 index 0000000..2b7207e --- /dev/null +++ b/TestSwift/ViewController.swift @@ -0,0 +1,25 @@ +// +// ViewController.swift +// TestSwift +// +// Created by Jameson Quave on 6/2/14. +// Copyright (c) 2014 JQ Software LLC. All rights reserved. +// + +import UIKit + +class ViewController: UIViewController { + + override func viewDidLoad() { + super.viewDidLoad() + // Do any additional setup after loading the view, typically from a nib. + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + + +} + diff --git a/TestSwiftTests/Info.plist b/TestSwiftTests/Info.plist new file mode 100644 index 0000000..a555585 --- /dev/null +++ b/TestSwiftTests/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + com.jqsoftware.${PRODUCT_NAME:rfc1034identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + + diff --git a/TestSwiftTests/TestSwiftTests.swift b/TestSwiftTests/TestSwiftTests.swift new file mode 100644 index 0000000..a311aa1 --- /dev/null +++ b/TestSwiftTests/TestSwiftTests.swift @@ -0,0 +1,35 @@ +// +// TestSwiftTests.swift +// TestSwiftTests +// +// Created by Jameson Quave on 6/2/14. +// Copyright (c) 2014 JQ Software LLC. All rights reserved. +// + +import XCTest + +class TestSwiftTests: XCTestCase { + + override func setUp() { + super.setUp() + // Put setup code here. This method is called before the invocation of each test method in the class. + } + + override func tearDown() { + // Put teardown code here. This method is called after the invocation of each test method in the class. + super.tearDown() + } + + func testExample() { + // This is an example of a functional test case. + XCTAssert(true, "Pass") + } + + func testPerformanceExample() { + // This is an example of a performance test case. + self.measureBlock() { + // Put the code you want to measure the time of here. + } + } + +} From e2ae686cad256f1d216247264eddf3c1ff4e7883 Mon Sep 17 00:00:00 2001 From: Jameson Quave Date: Tue, 3 Jun 2014 09:37:30 -0500 Subject: [PATCH 02/19] Part 3 --- TestSwift.xcodeproj/project.pbxproj | 18 +++- .../xcdebugger/Breakpoints_v2.xcbkptlist | 5 + .../xcschemes/TestSwift.xcscheme | 96 ++++++++++++++++++ .../xcschemes/xcschememanagement.plist | 27 +++++ TestSwift/APIController.swift | 62 +++++++++++ TestSwift/AppDelegate.swift | 2 +- TestSwift/Base.lproj/Main.storyboard | 23 ++++- TestSwift/Icon76.png | Bin 0 -> 7911 bytes .../timeline.xctimeline | 6 ++ TestSwift/SearchResultsViewController.swift | 61 +++++++++++ TestSwift/ViewController.swift | 25 ----- 11 files changed, 291 insertions(+), 34 deletions(-) create mode 100644 TestSwift.xcodeproj/xcuserdata/jquave.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist create mode 100644 TestSwift.xcodeproj/xcuserdata/jquave.xcuserdatad/xcschemes/TestSwift.xcscheme create mode 100644 TestSwift.xcodeproj/xcuserdata/jquave.xcuserdatad/xcschemes/xcschememanagement.plist create mode 100644 TestSwift/APIController.swift create mode 100644 TestSwift/Icon76.png create mode 100644 TestSwift/MyPlayground.playground/timeline.xctimeline create mode 100644 TestSwift/SearchResultsViewController.swift delete mode 100644 TestSwift/ViewController.swift diff --git a/TestSwift.xcodeproj/project.pbxproj b/TestSwift.xcodeproj/project.pbxproj index cc4b4a9..f49f0bb 100644 --- a/TestSwift.xcodeproj/project.pbxproj +++ b/TestSwift.xcodeproj/project.pbxproj @@ -7,11 +7,13 @@ objects = { /* Begin PBXBuildFile section */ + 026336BE193D3BB300765E31 /* Icon76.png in Resources */ = {isa = PBXBuildFile; fileRef = 026336BD193D3BB300765E31 /* Icon76.png */; }; 02CCF4A8193D16930069AEE9 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02CCF4A7193D16930069AEE9 /* AppDelegate.swift */; }; - 02CCF4AA193D16930069AEE9 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02CCF4A9193D16930069AEE9 /* ViewController.swift */; }; + 02CCF4AA193D16930069AEE9 /* SearchResultsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02CCF4A9193D16930069AEE9 /* SearchResultsViewController.swift */; }; 02CCF4AD193D16930069AEE9 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 02CCF4AB193D16930069AEE9 /* Main.storyboard */; }; 02CCF4AF193D16930069AEE9 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 02CCF4AE193D16930069AEE9 /* Images.xcassets */; }; 02CCF4BB193D16930069AEE9 /* TestSwiftTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02CCF4BA193D16930069AEE9 /* TestSwiftTests.swift */; }; + 02F504DB193E0B630037F599 /* APIController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02F504DA193E0B630037F599 /* APIController.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -25,15 +27,17 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 026336BD193D3BB300765E31 /* Icon76.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Icon76.png; sourceTree = ""; }; 02CCF4A2193D16930069AEE9 /* TestSwift.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TestSwift.app; sourceTree = BUILT_PRODUCTS_DIR; }; 02CCF4A6193D16930069AEE9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 02CCF4A7193D16930069AEE9 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; - 02CCF4A9193D16930069AEE9 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + 02CCF4A9193D16930069AEE9 /* SearchResultsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchResultsViewController.swift; sourceTree = ""; }; 02CCF4AC193D16930069AEE9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 02CCF4AE193D16930069AEE9 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 02CCF4B4193D16930069AEE9 /* TestSwiftTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TestSwiftTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 02CCF4B9193D16930069AEE9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 02CCF4BA193D16930069AEE9 /* TestSwiftTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestSwiftTests.swift; sourceTree = ""; }; + 02F504DA193E0B630037F599 /* APIController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = APIController.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -75,8 +79,10 @@ 02CCF4A4193D16930069AEE9 /* TestSwift */ = { isa = PBXGroup; children = ( + 026336BD193D3BB300765E31 /* Icon76.png */, 02CCF4A7193D16930069AEE9 /* AppDelegate.swift */, - 02CCF4A9193D16930069AEE9 /* ViewController.swift */, + 02CCF4A9193D16930069AEE9 /* SearchResultsViewController.swift */, + 02F504DA193E0B630037F599 /* APIController.swift */, 02CCF4AB193D16930069AEE9 /* Main.storyboard */, 02CCF4AE193D16930069AEE9 /* Images.xcassets */, 02CCF4A5193D16930069AEE9 /* Supporting Files */, @@ -191,6 +197,7 @@ files = ( 02CCF4AD193D16930069AEE9 /* Main.storyboard in Resources */, 02CCF4AF193D16930069AEE9 /* Images.xcassets in Resources */, + 026336BE193D3BB300765E31 /* Icon76.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -208,8 +215,9 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 02CCF4AA193D16930069AEE9 /* ViewController.swift in Sources */, + 02CCF4AA193D16930069AEE9 /* SearchResultsViewController.swift in Sources */, 02CCF4A8193D16930069AEE9 /* AppDelegate.swift in Sources */, + 02F504DB193E0B630037F599 /* APIController.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -399,6 +407,7 @@ 02CCF4C0193D16930069AEE9 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; 02CCF4C1193D16930069AEE9 /* Build configuration list for PBXNativeTarget "TestSwiftTests" */ = { isa = XCConfigurationList; @@ -407,6 +416,7 @@ 02CCF4C3193D16930069AEE9 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/TestSwift.xcodeproj/xcuserdata/jquave.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/TestSwift.xcodeproj/xcuserdata/jquave.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 0000000..fe2b454 --- /dev/null +++ b/TestSwift.xcodeproj/xcuserdata/jquave.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,5 @@ + + + diff --git a/TestSwift.xcodeproj/xcuserdata/jquave.xcuserdatad/xcschemes/TestSwift.xcscheme b/TestSwift.xcodeproj/xcuserdata/jquave.xcuserdatad/xcschemes/TestSwift.xcscheme new file mode 100644 index 0000000..5190fdf --- /dev/null +++ b/TestSwift.xcodeproj/xcuserdata/jquave.xcuserdatad/xcschemes/TestSwift.xcscheme @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/TestSwift.xcodeproj/xcuserdata/jquave.xcuserdatad/xcschemes/xcschememanagement.plist b/TestSwift.xcodeproj/xcuserdata/jquave.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..5f915f9 --- /dev/null +++ b/TestSwift.xcodeproj/xcuserdata/jquave.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,27 @@ + + + + + SchemeUserState + + TestSwift.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + 02CCF4A1193D16930069AEE9 + + primary + + + 02CCF4B3193D16930069AEE9 + + primary + + + + + diff --git a/TestSwift/APIController.swift b/TestSwift/APIController.swift new file mode 100644 index 0000000..2b7b38d --- /dev/null +++ b/TestSwift/APIController.swift @@ -0,0 +1,62 @@ +// +// APIController.swift +// TestSwift +// +// Created by Jameson Quave on 6/3/14. +// Copyright (c) 2014 JQ Software LLC. All rights reserved. +// + +import UIKit + +protocol APIControllerProtocol { + func didRecieveAPIResults(results: NSDictionary) +} + +class APIController: NSObject { + + var data: NSMutableData = NSMutableData() + var delegate: APIControllerProtocol? + + func searchItunesFor(searchTerm: String) { + + // The iTunes API wants multiple terms separated by + symbols, so replace spaces with + signs + var itunesSearchTerm = searchTerm.stringByReplacingOccurrencesOfString(" ", withString: "+", options: NSStringCompareOptions.CaseInsensitiveSearch, range: nil) + + // Now escape anything else that isn't URL-friendly + var escapedSearchTerm = itunesSearchTerm.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding) + var urlPath = "https://itunes.apple.com/search?term=\(escapedSearchTerm)&media=software" + var url: NSURL = NSURL(string: urlPath) + var request: NSURLRequest = NSURLRequest(URL: url) + var connection: NSURLConnection = NSURLConnection(request: request, delegate: self, startImmediately: false) + + connection.start() + } + + + func connection(connection: NSURLConnection!, didFailWithError error: NSError!) { + println("Connection failed.\(error.localizedDescription)") + } + + + func connection(didReceiveResponse: NSURLConnection!, didReceiveResponse response: NSURLResponse!) { + // Recieved a new request, clear out the data object + self.data = NSMutableData() + } + + func connection(connection: NSURLConnection!, didReceiveData data: NSData!) { + // Append the recieved chunk of data to our data object + self.data.appendData(data) + } + + func connectionDidFinishLoading(connection: NSURLConnection!) { + // Request complete, self.data should now hold the resulting info + // Convert the retrieved data in to an object through JSON deserialization + var err: NSError + var jsonResult: NSDictionary = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers, error: nil) as NSDictionary + + // Now send the JSON result to our delegate object + delegate?.didRecieveAPIResults(jsonResult) + } + + +} diff --git a/TestSwift/AppDelegate.swift b/TestSwift/AppDelegate.swift index ff3b3ec..1620adf 100644 --- a/TestSwift/AppDelegate.swift +++ b/TestSwift/AppDelegate.swift @@ -15,7 +15,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool { - // Override point for customization after application launch. + return true } diff --git a/TestSwift/Base.lproj/Main.storyboard b/TestSwift/Base.lproj/Main.storyboard index 5ee93c5..1396e91 100644 --- a/TestSwift/Base.lproj/Main.storyboard +++ b/TestSwift/Base.lproj/Main.storyboard @@ -1,13 +1,13 @@ - + - + - + - + @@ -15,11 +15,26 @@ + + + + + + + + + + + + + + + diff --git a/TestSwift/Icon76.png b/TestSwift/Icon76.png new file mode 100644 index 0000000000000000000000000000000000000000..2fa2c1ff581b36cdcd8bb916aff2cae2dc2df85e GIT binary patch literal 7911 zcmbVxbyQSu*ES{HNC-%afYgxEF~iV}3@tVE5W^td-QC>{f;32oG)M>tqVy0d4H5(L z;qyGd=llM6*Za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zjWx(P>e|*&AkI@{C8gZpnGda1m{z8K(O|&!wO~S<5-+s~u0zG9Muk*D(~@_t!j2+l zh(V+nzIdL+i&`suqu_^JDn_DkRHfV&E@zL?OcNOEsHbw0^SJ!LPh~|!S|@u0N*X2C zE>8fpBbJ~?d<*x;QufzkUT*{Ks`RbHvX*r30Q+g7m;mpOah9M?*sIm?p>5;Qo#=goL z%igV|fHZgzHP2HFa>Ho!Nb`r3hC3OtwsSEt6%*(Ud8pb2>56k%F*&7*SGcX;y=Q$K zU4LTcrTIPnM*XqjX~?pG{BWP)8CK)a=7Mz(nOjfRR<4>4IuFFV*BS}QFQWbV?iWt; zD1G+q;`mcsviOl*8yl|%EjvA~1lSkH*7_Iv7SJ%ejIx+7UACORW=dC_n7+5E%yw41 zRIXSq5aR3BZ=lL=j9P#;afReL%<9sBN7-oB_TLULq_p9se(h@=68V(0c+z?8ZAK76 zCn&hJwbg1A4=eqi(&i&1(qh}U+b-_x0{Psk(;{q>Enqcn%30k$t%qXY+YC)ftr=ps zXlF=v+<&={L76xbdwnY}Jq-&|g)}B4Bz(<4mY_N(PD{W2juk)VOVbzCCtq-}+q3hH z{fv+P?2DMoJ1Dhj+}O25YN|uyBg1)zQn&q6q#g_U3T~Fn4yMu-`K106&8mkFnuRPC z_TAmx%AFmSBBMekd{-MddDBX|2F_lrh-U9$xSQj}T^n-G8)S5}r>)Igy#N#J&<1lIvKQ5Rayo%~66~bE*LKhyw|g{=O07{#m}JK# zjWCV==&6zKvvrE(t~-)QZ8XrI@d-@X-?>s^JDpWze7b)$ovG65ZYV-H$T6iq1#zgJU@O!Y}br*T}-}@ z(l4<}IF5F-fu$`!dIZmkx}q|%?>8+x_b{GL1?y1~9bJ1^n + + + + diff --git a/TestSwift/SearchResultsViewController.swift b/TestSwift/SearchResultsViewController.swift new file mode 100644 index 0000000..6f81925 --- /dev/null +++ b/TestSwift/SearchResultsViewController.swift @@ -0,0 +1,61 @@ +// +// ViewController.swift +// TestSwift +// +// Created by Jameson Quave on 6/2/14. +// Copyright (c) 2014 JQ Software LLC. All rights reserved. +// + +import UIKit + +class SearchResultsViewController: UIViewController, UITableViewDataSource, UITableViewDelegate, APIControllerProtocol { + + var api: APIController = APIController() + @IBOutlet var appsTableView : UITableView + var tableData: NSArray = NSArray() + + override func viewDidLoad() { + super.viewDidLoad() + api.delegate = self + UIApplication.sharedApplication().networkActivityIndicatorVisible = true + api.searchItunesFor("Angry Birds"); + } + + func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int { + return tableData.count + } + + + func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! { + let cell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "MyTestCell") + + var rowData: NSDictionary = self.tableData[indexPath.row] as NSDictionary + + cell.text = rowData["trackName"] as String + + // Grab the artworkUrl60 key to get an image URL for the app's thumbnail + var urlString: NSString = rowData["artworkUrl60"] as NSString + var imgURL: NSURL = NSURL(string: urlString) + + // Download an NSData representation of the image at the URL + var imgData: NSData = NSData(contentsOfURL: imgURL) + cell.image = UIImage(data: imgData) + + // Get the formatted price string for display in the subtitle + var formattedPrice: NSString = rowData["formattedPrice"] as NSString + + cell.detailTextLabel.text = formattedPrice + + return cell + } + + func didRecieveAPIResults(results: NSDictionary) { + // Store the results in our table data array + if results.count>0 { + self.tableData = results["results"] as NSArray + self.appsTableView.reloadData() + UIApplication.sharedApplication().networkActivityIndicatorVisible = false + } + } + +} \ No newline at end of file diff --git a/TestSwift/ViewController.swift b/TestSwift/ViewController.swift deleted file mode 100644 index 2b7207e..0000000 --- a/TestSwift/ViewController.swift +++ /dev/null @@ -1,25 +0,0 @@ -// -// ViewController.swift -// TestSwift -// -// Created by Jameson Quave on 6/2/14. -// Copyright (c) 2014 JQ Software LLC. All rights reserved. -// - -import UIKit - -class ViewController: UIViewController { - - override func viewDidLoad() { - super.viewDidLoad() - // Do any additional setup after loading the view, typically from a nib. - } - - override func didReceiveMemoryWarning() { - super.didReceiveMemoryWarning() - // Dispose of any resources that can be recreated. - } - - -} - From 5471087e9d480fa6abf981e04c427c048bf442ec Mon Sep 17 00:00:00 2001 From: Jameson Quave Date: Tue, 3 Jun 2014 12:19:39 -0500 Subject: [PATCH 03/19] Part 4 --- TestSwift.xcodeproj/project.pbxproj | 4 --- TestSwift/Base.lproj/Main.storyboard | 22 +++++++++++++ TestSwift/Icon76.png | Bin 7911 -> 0 bytes TestSwift/SearchResultsViewController.swift | 34 ++++++++++++++++++-- 4 files changed, 54 insertions(+), 6 deletions(-) delete mode 100644 TestSwift/Icon76.png diff --git a/TestSwift.xcodeproj/project.pbxproj b/TestSwift.xcodeproj/project.pbxproj index f49f0bb..babf1b7 100644 --- a/TestSwift.xcodeproj/project.pbxproj +++ b/TestSwift.xcodeproj/project.pbxproj @@ -7,7 +7,6 @@ objects = { /* Begin PBXBuildFile section */ - 026336BE193D3BB300765E31 /* Icon76.png in Resources */ = {isa = PBXBuildFile; fileRef = 026336BD193D3BB300765E31 /* Icon76.png */; }; 02CCF4A8193D16930069AEE9 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02CCF4A7193D16930069AEE9 /* AppDelegate.swift */; }; 02CCF4AA193D16930069AEE9 /* SearchResultsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02CCF4A9193D16930069AEE9 /* SearchResultsViewController.swift */; }; 02CCF4AD193D16930069AEE9 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 02CCF4AB193D16930069AEE9 /* Main.storyboard */; }; @@ -27,7 +26,6 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ - 026336BD193D3BB300765E31 /* Icon76.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Icon76.png; sourceTree = ""; }; 02CCF4A2193D16930069AEE9 /* TestSwift.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TestSwift.app; sourceTree = BUILT_PRODUCTS_DIR; }; 02CCF4A6193D16930069AEE9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 02CCF4A7193D16930069AEE9 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; @@ -79,7 +77,6 @@ 02CCF4A4193D16930069AEE9 /* TestSwift */ = { isa = PBXGroup; children = ( - 026336BD193D3BB300765E31 /* Icon76.png */, 02CCF4A7193D16930069AEE9 /* AppDelegate.swift */, 02CCF4A9193D16930069AEE9 /* SearchResultsViewController.swift */, 02F504DA193E0B630037F599 /* APIController.swift */, @@ -197,7 +194,6 @@ files = ( 02CCF4AD193D16930069AEE9 /* Main.storyboard in Resources */, 02CCF4AF193D16930069AEE9 /* Images.xcassets in Resources */, - 026336BE193D3BB300765E31 /* Icon76.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/TestSwift/Base.lproj/Main.storyboard b/TestSwift/Base.lproj/Main.storyboard index 1396e91..c357dbf 100644 --- a/TestSwift/Base.lproj/Main.storyboard +++ b/TestSwift/Base.lproj/Main.storyboard @@ -19,6 +19,28 @@ + + + + + + + + + + + + diff --git a/TestSwift/Icon76.png b/TestSwift/Icon76.png deleted file mode 100644 index 2fa2c1ff581b36cdcd8bb916aff2cae2dc2df85e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7911 zcmbVxbyQSu*ES{HNC-%afYgxEF~iV}3@tVE5W^td-QC>{f;32oG)M>tqVy0d4H5(L z;qyGd=llM6*ZaqJ);Z^{eO>$7``-6jXRQ;hrJ+cKPm7O+hDM~U1k!nE)&4%X7!Ply zi($Wq<_SW<0HNz*gYdL~L($}{T`ZwY$}kICs1DS^+S_dmDv5@MX=krzfG|*36Ss1K z@ml<~;q`*KKA_RiBxSr@Evy`&2qsIYt-Z4p%Tae93zNOI6bnRHonPG*2(`0U@_|Ej zeKho}d>pOBtXX8FnIyf$9|&Mj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2HFa>Ho!Nb`r3hC3OtwsSEt6%*(Ud8pb2>56k%F*&7*SGcX;y=Q$K zU4LTcrTIPnM*XqjX~?pG{BWP)8CK)a=7Mz(nOjfRR<4>4IuFFV*BS}QFQWbV?iWt; zD1G+q;`mcsviOl*8yl|%EjvA~1lSkH*7_Iv7SJ%ejIx+7UACORW=dC_n7+5E%yw41 zRIXSq5aR3BZ=lL=j9P#;afReL%<9sBN7-oB_TLULq_p9se(h@=68V(0c+z?8ZAK76 zCn&hJwbg1A4=eqi(&i&1(qh}U+b-_x0{Psk(;{q>Enqcn%30k$t%qXY+YC)ftr=ps zXlF=v+<&={L76xbdwnY}Jq-&|g)}B4Bz(<4mY_N(PD{W2juk)VOVbzCCtq-}+q3hH z{fv+P?2DMoJ1Dhj+}O25YN|uyBg1)zQn&q6q#g_U3T~Fn4yMu-`K106&8mkFnuRPC z_TAmx%AFmSBBMekd{-MddDBX|2F_lrh-U9$xSQj}T^n-G8)S5}r>)Igy#N#J&<1lIvKQ5Rayo%~66~bE*LKhyw|g{=O07{#m}JK# zjWCV==&6zKvvrE(t~-)QZ8XrI@d-@X-?>s^JDpWze7b)$ovG65ZYV-H$T6iq1#zgJU@O!Y}br*T}-}@ z(l4<}IF5F-fu$`!dIZmkx}q|%?>8+x_b{GL1?y1~9bJ1^n UITableViewCell! { - let cell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "MyTestCell") + + var cell: UITableViewCell = tableView.dequeueReusableCellWithIdentifier(kCellIdentifier) as UITableViewCell + if cell == nil { + cell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: kCellIdentifier) + } var rowData: NSDictionary = self.tableData[indexPath.row] as NSDictionary @@ -58,4 +64,28 @@ class SearchResultsViewController: UIViewController, UITableViewDataSource, UITa } } -} \ No newline at end of file + func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!) { + + // Get the row data for the selected row + var rowData: NSDictionary = self.tableData[indexPath.row] as NSDictionary + println(rowData) + + var name: String = rowData["trackName"] as String + var formattedPrice: String = rowData["formattedPrice"] as String + + var alert: UIAlertView = UIAlertView() + alert.title = name + alert.message = formattedPrice + alert.addButtonWithTitle("Ok") + alert.show() + + } + +} + + + + + + + From c0571696aaee8c5ac6942e294ba5f5d366ba4382 Mon Sep 17 00:00:00 2001 From: Jameson Quave Date: Wed, 4 Jun 2014 11:33:03 -0500 Subject: [PATCH 04/19] Part5 Async image cells --- TestSwift/SearchResultsViewController.swift | 42 +++++++++++++++++---- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/TestSwift/SearchResultsViewController.swift b/TestSwift/SearchResultsViewController.swift index 6f81925..b47c118 100644 --- a/TestSwift/SearchResultsViewController.swift +++ b/TestSwift/SearchResultsViewController.swift @@ -13,6 +13,7 @@ class SearchResultsViewController: UIViewController, UITableViewDataSource, UITa var api: APIController = APIController() @IBOutlet var appsTableView : UITableView var tableData: NSArray = NSArray() + var imageCache = NSMutableArray() override func viewDidLoad() { super.viewDidLoad() @@ -32,17 +33,42 @@ class SearchResultsViewController: UIViewController, UITableViewDataSource, UITa var rowData: NSDictionary = self.tableData[indexPath.row] as NSDictionary cell.text = rowData["trackName"] as String - - // Grab the artworkUrl60 key to get an image URL for the app's thumbnail - var urlString: NSString = rowData["artworkUrl60"] as NSString - var imgURL: NSURL = NSURL(string: urlString) - - // Download an NSData representation of the image at the URL - var imgData: NSData = NSData(contentsOfURL: imgURL) - cell.image = UIImage(data: imgData) + cell.image = UIImage(named: "Icon76") + // Get the formatted price string for display in the subtitle var formattedPrice: NSString = rowData["formattedPrice"] as NSString + + dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), { + + // Grab the artworkUrl60 key to get an image URL for the app's thumbnail + var urlString: NSString = rowData["artworkUrl60"] as NSString + //var image: UIImage? = self.imageCache[urlString] as? UIImage + var image: UIImage? = self.imageCache.valueForKey(urlString) as? UIImage + if( !image? ) { + var imgURL: NSURL = NSURL(string: urlString) + + // Download an NSData representation of the image at the URL + var imgData: NSData = NSData(contentsOfURL: imgURL) + image = UIImage(data: imgData) + self.imageCache.setValue(image, forKey: urlString) +// self.imageCache[urlString] = image + } + dispatch_async(dispatch_get_main_queue()) { + var sCell: UITableViewCell? = tableView.cellForRowAtIndexPath(indexPath) + if sCell != nil { + let pCell: UITableViewCell = sCell! + pCell.image = image + println("set cell to \(image?.size.width)") + cell.image = image + + } + println("attempt to set cell") + } + + }) + + tableView.indexPathForCell(cell) cell.detailTextLabel.text = formattedPrice From 0c0fc6789666f612fcccf0ba64d242e685c4d592 Mon Sep 17 00:00:00 2001 From: Jameson Quave Date: Wed, 4 Jun 2014 11:48:00 -0500 Subject: [PATCH 05/19] Comments --- TestSwift/SearchResultsViewController.swift | 24 +++++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/TestSwift/SearchResultsViewController.swift b/TestSwift/SearchResultsViewController.swift index b47c118..7cf350d 100644 --- a/TestSwift/SearchResultsViewController.swift +++ b/TestSwift/SearchResultsViewController.swift @@ -40,30 +40,40 @@ class SearchResultsViewController: UIViewController, UITableViewDataSource, UITa var formattedPrice: NSString = rowData["formattedPrice"] as NSString dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), { + // Jump in to a background thread to get the image for this item // Grab the artworkUrl60 key to get an image URL for the app's thumbnail var urlString: NSString = rowData["artworkUrl60"] as NSString - //var image: UIImage? = self.imageCache[urlString] as? UIImage + + // Check our image cache for the existing key. This is just a dictionary of UIImages var image: UIImage? = self.imageCache.valueForKey(urlString) as? UIImage + if( !image? ) { + // If the image does not exist, we need to download it var imgURL: NSURL = NSURL(string: urlString) + println("Download the image \(imgURL)") // Download an NSData representation of the image at the URL var imgData: NSData = NSData(contentsOfURL: imgURL) image = UIImage(data: imgData) + + // Store the image in to our cache self.imageCache.setValue(image, forKey: urlString) -// self.imageCache[urlString] = image + + println("Image downloaded") } dispatch_async(dispatch_get_main_queue()) { + // Back on the main thread, let's set the image view of the cell to use our amazing new image + // First, we need to make sure the cell hasn't gone off the screen, or worse, been re-used + // Validate the cell is still available by using cellForRowAtIndexPath var sCell: UITableViewCell? = tableView.cellForRowAtIndexPath(indexPath) - if sCell != nil { + + // If the cell exists, we're good and we can update it with this image + if sCell? { let pCell: UITableViewCell = sCell! pCell.image = image - println("set cell to \(image?.size.width)") - cell.image = image - + println("set image") } - println("attempt to set cell") } }) From 9e147fa75b9d2ca68afc0d123a655e886a8d47d3 Mon Sep 17 00:00:00 2001 From: Jameson Quave Date: Wed, 4 Jun 2014 11:50:24 -0500 Subject: [PATCH 06/19] Create README.md --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..eea40b0 --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +Swift-Tutorial +============== + +Code for the Swift Tutorial on jamesonquave.com + +Hi everyone! This is the code for my ongoing tutorial for Swift iOS development on jamesonquave.com + +Each part of the tutorial has it's own branch, so if you want to follow along use the branch for each part, master will represent the most up to date version from the latest tutorial. +Feedback and comments are welcome! From 09423195df849abf93270254902ce23ca2de8950 Mon Sep 17 00:00:00 2001 From: Jameson Quave Date: Wed, 4 Jun 2014 12:00:06 -0500 Subject: [PATCH 07/19] Fast image loading using async NSURLRequest --- TestSwift/SearchResultsViewController.swift | 51 ++++++++++++--------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/TestSwift/SearchResultsViewController.swift b/TestSwift/SearchResultsViewController.swift index acd0229..f8340f5 100644 --- a/TestSwift/SearchResultsViewController.swift +++ b/TestSwift/SearchResultsViewController.swift @@ -58,30 +58,39 @@ class SearchResultsViewController: UIViewController, UITableViewDataSource, UITa // If the image does not exist, we need to download it var imgURL: NSURL = NSURL(string: urlString) - println("Download the image \(imgURL)") // Download an NSData representation of the image at the URL - var imgData: NSData = NSData(contentsOfURL: imgURL) - image = UIImage(data: imgData) - - // Store the image in to our cache - self.imageCache.setValue(image, forKey: urlString) - - println("Image downloaded") - } - dispatch_async(dispatch_get_main_queue()) { - // Back on the main thread, let's set the image view of the cell to use our amazing new image - // First, we need to make sure the cell hasn't gone off the screen, or worse, been re-used - // Validate the cell is still available by using cellForRowAtIndexPath - var sCell: UITableViewCell? = tableView.cellForRowAtIndexPath(indexPath) - - // If the cell exists, we're good and we can update it with this image - if sCell? { - let pCell: UITableViewCell = sCell! - pCell.image = image - println("set image") - } + var request: NSURLRequest = NSURLRequest(URL: imgURL) + var urlConnection: NSURLConnection = NSURLConnection(request: request, delegate: self) + NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue(), completionHandler: {(response: NSURLResponse!,data: NSData!,error: NSError!) -> Void in + if !error? { + //var imgData: NSData = NSData(contentsOfURL: imgURL) + image = UIImage(data: data) + + // Store the image in to our cache + self.imageCache.setValue(image, forKey: urlString) + cell.image = image + + dispatch_async(dispatch_get_main_queue()) { + // Back on the main thread, let's set the image view of the cell to use our amazing new image + // First, we need to make sure the cell hasn't gone off the screen, or worse, been re-used + // Validate the cell is still available by using cellForRowAtIndexPath + var sCell: UITableViewCell? = tableView.cellForRowAtIndexPath(indexPath) + + // If the cell exists, we're good and we can update it with this image + if sCell? { + let pCell: UITableViewCell = sCell! + pCell.image = image + } + } + } + else { + println("Error: \(error.localizedDescription)") + } + }) + } + }) tableView.indexPathForCell(cell) From 4284494ad60720f66402ce4076d87218480acf5d Mon Sep 17 00:00:00 2001 From: Jameson Quave Date: Wed, 4 Jun 2014 12:00:17 -0500 Subject: [PATCH 08/19] Part 5 --- TestSwift/SearchResultsViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TestSwift/SearchResultsViewController.swift b/TestSwift/SearchResultsViewController.swift index f8340f5..77e16ec 100644 --- a/TestSwift/SearchResultsViewController.swift +++ b/TestSwift/SearchResultsViewController.swift @@ -34,7 +34,7 @@ class SearchResultsViewController: UIViewController, UITableViewDataSource, UITa var cell: UITableViewCell = tableView.dequeueReusableCellWithIdentifier(kCellIdentifier) as UITableViewCell if cell == nil { cell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: kCellIdentifier) - } + } var rowData: NSDictionary = self.tableData[indexPath.row] as NSDictionary From 10d29604b85d49e5e55861d0b45f0db61be261cf Mon Sep 17 00:00:00 2001 From: Jameson Quave Date: Wed, 4 Jun 2014 12:05:35 -0500 Subject: [PATCH 09/19] Part 5 --- TestSwift/SearchResultsViewController.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/TestSwift/SearchResultsViewController.swift b/TestSwift/SearchResultsViewController.swift index 77e16ec..d0cd392 100644 --- a/TestSwift/SearchResultsViewController.swift +++ b/TestSwift/SearchResultsViewController.swift @@ -38,7 +38,9 @@ class SearchResultsViewController: UIViewController, UITableViewDataSource, UITa var rowData: NSDictionary = self.tableData[indexPath.row] as NSDictionary - cell.text = rowData["trackName"] as String + // Add a check to make sure this exists + let cellText: String? = rowData["trackName"] as? String + cell.text = cellText cell.image = UIImage(named: "Icon76") From d86ef36b294d105daf64c26d8cc08e4b776dee2f Mon Sep 17 00:00:00 2001 From: Jameson Quave Date: Wed, 4 Jun 2014 12:24:50 -0500 Subject: [PATCH 10/19] Part 5 --- TestSwift/SearchResultsViewController.swift | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/TestSwift/SearchResultsViewController.swift b/TestSwift/SearchResultsViewController.swift index d0cd392..a8780b3 100644 --- a/TestSwift/SearchResultsViewController.swift +++ b/TestSwift/SearchResultsViewController.swift @@ -71,19 +71,6 @@ class SearchResultsViewController: UIViewController, UITableViewDataSource, UITa // Store the image in to our cache self.imageCache.setValue(image, forKey: urlString) cell.image = image - - dispatch_async(dispatch_get_main_queue()) { - // Back on the main thread, let's set the image view of the cell to use our amazing new image - // First, we need to make sure the cell hasn't gone off the screen, or worse, been re-used - // Validate the cell is still available by using cellForRowAtIndexPath - var sCell: UITableViewCell? = tableView.cellForRowAtIndexPath(indexPath) - - // If the cell exists, we're good and we can update it with this image - if sCell? { - let pCell: UITableViewCell = sCell! - pCell.image = image - } - } } else { println("Error: \(error.localizedDescription)") From d6778016cf66e42f9dd44bb81ee41363b5db4888 Mon Sep 17 00:00:00 2001 From: Jameson Quave Date: Wed, 4 Jun 2014 13:04:28 -0500 Subject: [PATCH 11/19] Part 5 --- TestSwift/SearchResultsViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TestSwift/SearchResultsViewController.swift b/TestSwift/SearchResultsViewController.swift index a8780b3..b83ac7f 100644 --- a/TestSwift/SearchResultsViewController.swift +++ b/TestSwift/SearchResultsViewController.swift @@ -15,7 +15,7 @@ class SearchResultsViewController: UIViewController, UITableViewDataSource, UITa var api: APIController = APIController() @IBOutlet var appsTableView : UITableView var tableData: NSArray = NSArray() - var imageCache = NSMutableArray() + var imageCache = NSMutableDictionary() override func viewDidLoad() { super.viewDidLoad() From e77ccdb7dc29d79a7d4913ab3e2834e845f7d70c Mon Sep 17 00:00:00 2001 From: Jameson Quave Date: Wed, 4 Jun 2014 13:05:48 -0500 Subject: [PATCH 12/19] Part 5 --- TestSwift/SearchResultsViewController.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/TestSwift/SearchResultsViewController.swift b/TestSwift/SearchResultsViewController.swift index b83ac7f..a806000 100644 --- a/TestSwift/SearchResultsViewController.swift +++ b/TestSwift/SearchResultsViewController.swift @@ -78,6 +78,9 @@ class SearchResultsViewController: UIViewController, UITableViewDataSource, UITa }) } + else { + cell.image = image + } }) From d4e368e60e9f274fb30d693a3d76f0502899005a Mon Sep 17 00:00:00 2001 From: Jameson Quave Date: Wed, 4 Jun 2014 13:08:12 -0500 Subject: [PATCH 13/19] Part 5 --- TestSwift.xcodeproj/project.pbxproj | 4 ++++ TestSwift/Blank52.png | Bin 0 -> 975 bytes TestSwift/SearchResultsViewController.swift | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 TestSwift/Blank52.png diff --git a/TestSwift.xcodeproj/project.pbxproj b/TestSwift.xcodeproj/project.pbxproj index babf1b7..971b4df 100644 --- a/TestSwift.xcodeproj/project.pbxproj +++ b/TestSwift.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 0229AE63193F97EF00BCED97 /* Blank52.png in Resources */ = {isa = PBXBuildFile; fileRef = 0229AE62193F97EF00BCED97 /* Blank52.png */; }; 02CCF4A8193D16930069AEE9 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02CCF4A7193D16930069AEE9 /* AppDelegate.swift */; }; 02CCF4AA193D16930069AEE9 /* SearchResultsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02CCF4A9193D16930069AEE9 /* SearchResultsViewController.swift */; }; 02CCF4AD193D16930069AEE9 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 02CCF4AB193D16930069AEE9 /* Main.storyboard */; }; @@ -26,6 +27,7 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 0229AE62193F97EF00BCED97 /* Blank52.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Blank52.png; sourceTree = ""; }; 02CCF4A2193D16930069AEE9 /* TestSwift.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TestSwift.app; sourceTree = BUILT_PRODUCTS_DIR; }; 02CCF4A6193D16930069AEE9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 02CCF4A7193D16930069AEE9 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; @@ -77,6 +79,7 @@ 02CCF4A4193D16930069AEE9 /* TestSwift */ = { isa = PBXGroup; children = ( + 0229AE62193F97EF00BCED97 /* Blank52.png */, 02CCF4A7193D16930069AEE9 /* AppDelegate.swift */, 02CCF4A9193D16930069AEE9 /* SearchResultsViewController.swift */, 02F504DA193E0B630037F599 /* APIController.swift */, @@ -192,6 +195,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 0229AE63193F97EF00BCED97 /* Blank52.png in Resources */, 02CCF4AD193D16930069AEE9 /* Main.storyboard in Resources */, 02CCF4AF193D16930069AEE9 /* Images.xcassets in Resources */, ); diff --git a/TestSwift/Blank52.png b/TestSwift/Blank52.png new file mode 100644 index 0000000000000000000000000000000000000000..132e1868cd27834d7e89b56a79dde9c1c1aef57a GIT binary patch literal 975 zcmaJ=zi-n(6h0_IrBVk*I-T4OAQ3yZW0zPlRU9YO2uD#8K}H<=l31yI=6u0U79=DF zB>n(a{sFeC14zs)3I9__gg3?E0L z$1!3aC5#O~IkqV<4KWM@W4}=^YnoE3t9nhA>#C*dR<&x`ilu6IY+G4!ZR}4X z6w@U)IOl3>xx5*ogn70R37?{%L2v};mo~!nu_$Zx7TjQcEb3aW#DbA{Y5ytp(!~0Q zZ&!`W4y)EjG3$528asM({F*(As$*BX`L|!6 literal 0 HcmV?d00001 diff --git a/TestSwift/SearchResultsViewController.swift b/TestSwift/SearchResultsViewController.swift index a806000..8a1a6e0 100644 --- a/TestSwift/SearchResultsViewController.swift +++ b/TestSwift/SearchResultsViewController.swift @@ -41,7 +41,7 @@ class SearchResultsViewController: UIViewController, UITableViewDataSource, UITa // Add a check to make sure this exists let cellText: String? = rowData["trackName"] as? String cell.text = cellText - cell.image = UIImage(named: "Icon76") + cell.image = UIImage(named: "Blank52") // Get the formatted price string for display in the subtitle From 0f5830e8323fd12185968fafa57b6f317ea0d179 Mon Sep 17 00:00:00 2001 From: Jameson Quave Date: Wed, 4 Jun 2014 20:15:59 -0500 Subject: [PATCH 14/19] Part 6 --- TestSwift.xcodeproj/project.pbxproj | 10 ++ .../xcdebugger/Breakpoints_v2.xcbkptlist | 110 ++++++++++++++ TestSwift/APIController.swift | 52 +++---- TestSwift/Base.lproj/Main.storyboard | 56 ++++++- TestSwift/Classes/Album.swift | 30 ++++ TestSwift/Classes/DetailsViewController.swift | 31 ++++ TestSwift/SearchResultsViewController.swift | 142 +++++++++++++----- 7 files changed, 361 insertions(+), 70 deletions(-) create mode 100644 TestSwift/Classes/Album.swift create mode 100644 TestSwift/Classes/DetailsViewController.swift diff --git a/TestSwift.xcodeproj/project.pbxproj b/TestSwift.xcodeproj/project.pbxproj index 971b4df..a34de65 100644 --- a/TestSwift.xcodeproj/project.pbxproj +++ b/TestSwift.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 022889EF193FC3AC00D729A0 /* DetailsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 022889EE193FC3AC00D729A0 /* DetailsViewController.swift */; }; + 022889F1193FD6C000D729A0 /* Album.swift in Sources */ = {isa = PBXBuildFile; fileRef = 022889F0193FD6C000D729A0 /* Album.swift */; }; 0229AE63193F97EF00BCED97 /* Blank52.png in Resources */ = {isa = PBXBuildFile; fileRef = 0229AE62193F97EF00BCED97 /* Blank52.png */; }; 02CCF4A8193D16930069AEE9 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02CCF4A7193D16930069AEE9 /* AppDelegate.swift */; }; 02CCF4AA193D16930069AEE9 /* SearchResultsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02CCF4A9193D16930069AEE9 /* SearchResultsViewController.swift */; }; @@ -27,6 +29,8 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 022889EE193FC3AC00D729A0 /* DetailsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = DetailsViewController.swift; path = Classes/DetailsViewController.swift; sourceTree = ""; }; + 022889F0193FD6C000D729A0 /* Album.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Album.swift; path = Classes/Album.swift; sourceTree = ""; }; 0229AE62193F97EF00BCED97 /* Blank52.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Blank52.png; sourceTree = ""; }; 02CCF4A2193D16930069AEE9 /* TestSwift.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TestSwift.app; sourceTree = BUILT_PRODUCTS_DIR; }; 02CCF4A6193D16930069AEE9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -80,9 +84,11 @@ isa = PBXGroup; children = ( 0229AE62193F97EF00BCED97 /* Blank52.png */, + 022889F0193FD6C000D729A0 /* Album.swift */, 02CCF4A7193D16930069AEE9 /* AppDelegate.swift */, 02CCF4A9193D16930069AEE9 /* SearchResultsViewController.swift */, 02F504DA193E0B630037F599 /* APIController.swift */, + 022889EE193FC3AC00D729A0 /* DetailsViewController.swift */, 02CCF4AB193D16930069AEE9 /* Main.storyboard */, 02CCF4AE193D16930069AEE9 /* Images.xcassets */, 02CCF4A5193D16930069AEE9 /* Supporting Files */, @@ -218,6 +224,8 @@ 02CCF4AA193D16930069AEE9 /* SearchResultsViewController.swift in Sources */, 02CCF4A8193D16930069AEE9 /* AppDelegate.swift in Sources */, 02F504DB193E0B630037F599 /* APIController.swift in Sources */, + 022889EF193FC3AC00D729A0 /* DetailsViewController.swift in Sources */, + 022889F1193FD6C000D729A0 /* Album.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -336,6 +344,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; INFOPLIST_FILE = TestSwift/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 6.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_NAME = "$(TARGET_NAME)"; }; @@ -347,6 +356,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; INFOPLIST_FILE = TestSwift/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 6.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_NAME = "$(TARGET_NAME)"; }; diff --git a/TestSwift.xcodeproj/xcuserdata/jquave.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/TestSwift.xcodeproj/xcuserdata/jquave.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index fe2b454..bbdc787 100644 --- a/TestSwift.xcodeproj/xcuserdata/jquave.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/TestSwift.xcodeproj/xcuserdata/jquave.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -2,4 +2,114 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/TestSwift/APIController.swift b/TestSwift/APIController.swift index 2b7b38d..32dd145 100644 --- a/TestSwift/APIController.swift +++ b/TestSwift/APIController.swift @@ -24,39 +24,25 @@ class APIController: NSObject { // Now escape anything else that isn't URL-friendly var escapedSearchTerm = itunesSearchTerm.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding) - var urlPath = "https://itunes.apple.com/search?term=\(escapedSearchTerm)&media=software" + var urlPath = "https://itunes.apple.com/search?term=\(escapedSearchTerm)&media=music&entity=album" var url: NSURL = NSURL(string: urlPath) var request: NSURLRequest = NSURLRequest(URL: url) - var connection: NSURLConnection = NSURLConnection(request: request, delegate: self, startImmediately: false) - - connection.start() - } - - - func connection(connection: NSURLConnection!, didFailWithError error: NSError!) { - println("Connection failed.\(error.localizedDescription)") - } - - - func connection(didReceiveResponse: NSURLConnection!, didReceiveResponse response: NSURLResponse!) { - // Recieved a new request, clear out the data object - self.data = NSMutableData() - } - - func connection(connection: NSURLConnection!, didReceiveData data: NSData!) { - // Append the recieved chunk of data to our data object - self.data.appendData(data) - } - - func connectionDidFinishLoading(connection: NSURLConnection!) { - // Request complete, self.data should now hold the resulting info - // Convert the retrieved data in to an object through JSON deserialization - var err: NSError - var jsonResult: NSDictionary = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers, error: nil) as NSDictionary - - // Now send the JSON result to our delegate object - delegate?.didRecieveAPIResults(jsonResult) + + NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue(), completionHandler: {(response: NSURLResponse!,data: NSData!,error: NSError!) -> Void in + if error? { + println("ERROR: \(error.localizedDescription)") + } + else { + var error: NSError? + var jsonResult: NSDictionary = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers, error: &error) as NSDictionary + // Now send the JSON result to our delegate object + if error? { + println("HTTP Error: \(error?.localizedDescription)") + } + else { + self.delegate?.didRecieveAPIResults(jsonResult) + } + } + }) } - - -} +} \ No newline at end of file diff --git a/TestSwift/Base.lproj/Main.storyboard b/TestSwift/Base.lproj/Main.storyboard index c357dbf..76ff296 100644 --- a/TestSwift/Base.lproj/Main.storyboard +++ b/TestSwift/Base.lproj/Main.storyboard @@ -1,5 +1,5 @@ - + @@ -20,7 +20,7 @@ - + @@ -39,6 +39,9 @@ + + + @@ -50,13 +53,60 @@ + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/TestSwift/Classes/Album.swift b/TestSwift/Classes/Album.swift new file mode 100644 index 0000000..7666b0c --- /dev/null +++ b/TestSwift/Classes/Album.swift @@ -0,0 +1,30 @@ +// +// Album.swift +// TestSwift +// +// Created by Jameson Quave on 6/4/14. +// Copyright (c) 2014 JQ Software LLC. All rights reserved. +// + +import UIKit + +class Album: NSObject { + + var title: String = "N/A" + var price: String = "N/A" + var thumbnailImageURL: String? + var largeImageURL: String? + var itemURL: String? + var artistURL: String? + + + init(name: String, price: String, thumbnailImageURL: String, largeImageURL: String, itemURL: String, artistURL: String) { + self.title = name + self.price = price + self.thumbnailImageURL = thumbnailImageURL + self.largeImageURL = largeImageURL + self.itemURL = itemURL + self.artistURL = artistURL + } + +} diff --git a/TestSwift/Classes/DetailsViewController.swift b/TestSwift/Classes/DetailsViewController.swift new file mode 100644 index 0000000..afdc27d --- /dev/null +++ b/TestSwift/Classes/DetailsViewController.swift @@ -0,0 +1,31 @@ +// +// DetailsViewController.swift +// TestSwift +// +// Created by Jameson Quave on 6/4/14. +// Copyright (c) 2014 JQ Software LLC. All rights reserved. +// + +import UIKit + +class DetailsViewController: UIViewController { + + var detailInfo: NSDictionary? + + init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) { + super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) + // Custom initialization + } + + override func viewDidLoad() { + super.viewDidLoad() + + // Do any additional setup after loading the view. + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + +} diff --git a/TestSwift/SearchResultsViewController.swift b/TestSwift/SearchResultsViewController.swift index 8a1a6e0..ecaaa29 100644 --- a/TestSwift/SearchResultsViewController.swift +++ b/TestSwift/SearchResultsViewController.swift @@ -8,50 +8,77 @@ import UIKit -class SearchResultsViewController: UIViewController, UITableViewDataSource, UITableViewDelegate, APIControllerProtocol { +class SearchResultsViewController: UIViewController,/* UITableViewDataSource, UITableViewDelegate, */APIControllerProtocol { let kCellIdentifier: String = "SearchResultCell" var api: APIController = APIController() @IBOutlet var appsTableView : UITableView - var tableData: NSArray = NSArray() + + var tableData: Dictionary[] = [] + var albums: Album[] = [] + var imageCache = NSMutableDictionary() override func viewDidLoad() { super.viewDidLoad() api.delegate = self UIApplication.sharedApplication().networkActivityIndicatorVisible = true - api.searchItunesFor("Angry Birds"); + api.searchItunesFor("Bob Dylan"); + } + + override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject) { + + + if segue.identifier == "Details" { + //var detailsViewController: DetailsViewController? = segue.destinationViewController! as? DetailsViewController + + var destinationViewController: UIViewController = segue.destinationViewController as UIViewController + + // var detailsViewController: DetailsViewController = destinationViewController as DetailsViewController + + + //var destinationViewController: UIViewController! = segue.destinationViewController as UIViewController! + //var detailsViewController: DetailsViewController = destinationViewController as DetailsViewController +/* var selectedIndexPathRow = appsTableView.indexPathForSelectedRow().row + var selectedAppDetails: NSDictionary = self.tableData[selectedIndexPathRow] as NSDictionary + + detailsViewController.detailInfo = selectedAppDetails*/ + } } func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int { - return tableData.count + //return countElements(self.tableData) + //return self.tableData.count + return albums.count } func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! { + + var cell: UITableViewCell = tableView.dequeueReusableCellWithIdentifier(kCellIdentifier) as UITableViewCell if cell == nil { cell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: kCellIdentifier) } - var rowData: NSDictionary = self.tableData[indexPath.row] as NSDictionary + var index: Int = indexPath.row + + // Find this cell's album by passing in the Int 'index' to the subscript method for an array of type Album[] + var album = self.albums[index] - // Add a check to make sure this exists - let cellText: String? = rowData["trackName"] as? String - cell.text = cellText + cell.text = album.title cell.image = UIImage(named: "Blank52") - - // Get the formatted price string for display in the subtitle - var formattedPrice: NSString = rowData["formattedPrice"] as NSString + cell.detailTextLabel.text = album.price dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), { // Jump in to a background thread to get the image for this item // Grab the artworkUrl60 key to get an image URL for the app's thumbnail - var urlString: NSString = rowData["artworkUrl60"] as NSString + //var urlString: NSString = rowData["artworkUrl60"] as NSString + var urlString = album.thumbnailImageURL // Check our image cache for the existing key. This is just a dictionary of UIImages var image: UIImage? = self.imageCache.valueForKey(urlString) as? UIImage @@ -65,12 +92,19 @@ class SearchResultsViewController: UIViewController, UITableViewDataSource, UITa var urlConnection: NSURLConnection = NSURLConnection(request: request, delegate: self) NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue(), completionHandler: {(response: NSURLResponse!,data: NSData!,error: NSError!) -> Void in if !error? { - //var imgData: NSData = NSData(contentsOfURL: imgURL) image = UIImage(data: data) // Store the image in to our cache self.imageCache.setValue(image, forKey: urlString) - cell.image = image + + // Sometimes this request takes a while, and it's possible that a cell could be re-used before the art is done loading. + // Let's explicitly call the cellForRowAtIndexPath method of our tableView to make sure the cell is not nil, and therefore still showing onscreen. + // While this method sounds a lot like the method we're in right now, it isn't. + // Ctrl+Click on the method name to see how it's defined, including the following comment: + /** // returns nil if cell is not visible or index path is out of range **/ + if let albumArtsCell: UITableViewCell? = tableView.cellForRowAtIndexPath(indexPath) { + albumArtsCell!.image = image + } } else { println("Error: \(error.localizedDescription)") @@ -84,38 +118,64 @@ class SearchResultsViewController: UIViewController, UITableViewDataSource, UITa }) - - tableView.indexPathForCell(cell) - - cell.detailTextLabel.text = formattedPrice - return cell } func didRecieveAPIResults(results: NSDictionary) { // Store the results in our table data array if results.count>0 { - self.tableData = results["results"] as NSArray + + var allResults: NSDictionary[] = results["results"] as NSDictionary[] + + // var swiftResultArray: NSDictionary[] = allResults + + // Sometimes iTunes returns a collection, not a track, so we check both for the 'name' + for result: NSDictionary in allResults { + + var name: String? = result["trackName"] as? String + if !name? { + name = result["collectionName"] as? String + } + + // Sometimes price comes in as formattedPrice, sometimes as collectionPrice.. and sometimes it's a float instead of a string. Hooray! + var price: String? = result["formattedPrice"] as? String + if !price? { + price = result["collectionPrice"] as? String + if !price? { + var priceFloat: Float? = result["collectionPrice"] as? Float + println(priceFloat) + var nf: NSNumberFormatter = NSNumberFormatter() + nf.maximumFractionDigits = 2; + if priceFloat? { + price = "$"+nf.stringFromNumber(priceFloat) + } + } + } + + var thumbnailURL: String? = result["artworkUrl60"] as? String + var imageURL: String? = result["artworkUrl100"] as? String + + var artistURL: String? = result["artistViewUrl"] as? String + + var itemURL: String? = result["collectionViewUrl"] as? String + if !itemURL? { + itemURL = result["trackViewUrl"] as? String + } + + var newAlbum = Album(name: name!, price: price!, thumbnailImageURL: thumbnailURL!, largeImageURL: imageURL!, itemURL: itemURL!, artistURL: artistURL!) + + albums.append(newAlbum) + } + + self.appsTableView.reloadData() UIApplication.sharedApplication().networkActivityIndicatorVisible = false } } func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!) { - - // Get the row data for the selected row - var rowData: NSDictionary = self.tableData[indexPath.row] as NSDictionary - println(rowData) - - var name: String = rowData["trackName"] as String - var formattedPrice: String = rowData["formattedPrice"] as String - - var alert: UIAlertView = UIAlertView() - alert.title = name - alert.message = formattedPrice - alert.addButtonWithTitle("Ok") - alert.show() - + // Get the album for this row + var album = albums[indexPath.row] } } @@ -125,4 +185,18 @@ class SearchResultsViewController: UIViewController, UITableViewDataSource, UITa + + + + + + + + + + + + + + From a5f311a0cc80da37049bf6c6fc832ecc695cb7fc Mon Sep 17 00:00:00 2001 From: Jameson Quave Date: Wed, 4 Jun 2014 20:28:01 -0500 Subject: [PATCH 15/19] Part 6 --- TestSwift/APIController.swift | 14 ++++---- TestSwift/SearchResultsViewController.swift | 39 ++++++++------------- 2 files changed, 21 insertions(+), 32 deletions(-) diff --git a/TestSwift/APIController.swift b/TestSwift/APIController.swift index 32dd145..f4b677c 100644 --- a/TestSwift/APIController.swift +++ b/TestSwift/APIController.swift @@ -14,19 +14,19 @@ protocol APIControllerProtocol { class APIController: NSObject { - var data: NSMutableData = NSMutableData() + let data: NSMutableData = NSMutableData() var delegate: APIControllerProtocol? func searchItunesFor(searchTerm: String) { // The iTunes API wants multiple terms separated by + symbols, so replace spaces with + signs - var itunesSearchTerm = searchTerm.stringByReplacingOccurrencesOfString(" ", withString: "+", options: NSStringCompareOptions.CaseInsensitiveSearch, range: nil) + let itunesSearchTerm = searchTerm.stringByReplacingOccurrencesOfString(" ", withString: "+", options: NSStringCompareOptions.CaseInsensitiveSearch, range: nil) // Now escape anything else that isn't URL-friendly - var escapedSearchTerm = itunesSearchTerm.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding) - var urlPath = "https://itunes.apple.com/search?term=\(escapedSearchTerm)&media=music&entity=album" - var url: NSURL = NSURL(string: urlPath) - var request: NSURLRequest = NSURLRequest(URL: url) + let escapedSearchTerm = itunesSearchTerm.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding) + let urlPath = "https://itunes.apple.com/search?term=\(escapedSearchTerm)&media=music&entity=album" + let url: NSURL = NSURL(string: urlPath) + let request: NSURLRequest = NSURLRequest(URL: url) NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue(), completionHandler: {(response: NSURLResponse!,data: NSData!,error: NSError!) -> Void in if error? { @@ -34,7 +34,7 @@ class APIController: NSObject { } else { var error: NSError? - var jsonResult: NSDictionary = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers, error: &error) as NSDictionary + let jsonResult: NSDictionary = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers, error: &error) as NSDictionary // Now send the JSON result to our delegate object if error? { println("HTTP Error: \(error?.localizedDescription)") diff --git a/TestSwift/SearchResultsViewController.swift b/TestSwift/SearchResultsViewController.swift index ecaaa29..e8c6207 100644 --- a/TestSwift/SearchResultsViewController.swift +++ b/TestSwift/SearchResultsViewController.swift @@ -15,10 +15,9 @@ class SearchResultsViewController: UIViewController,/* UITableViewDataSource, UI var api: APIController = APIController() @IBOutlet var appsTableView : UITableView - var tableData: Dictionary[] = [] var albums: Album[] = [] - - var imageCache = NSMutableDictionary() + //var imageCache = NSMutableDictionary() + var imageCache = Dictionary() override func viewDidLoad() { super.viewDidLoad() @@ -48,25 +47,16 @@ class SearchResultsViewController: UIViewController,/* UITableViewDataSource, UI } func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int { - //return countElements(self.tableData) - //return self.tableData.count return albums.count } func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! { - - var cell: UITableViewCell = tableView.dequeueReusableCellWithIdentifier(kCellIdentifier) as UITableViewCell - if cell == nil { - cell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: kCellIdentifier) - } - var index: Int = indexPath.row - - // Find this cell's album by passing in the Int 'index' to the subscript method for an array of type Album[] - var album = self.albums[index] + // Find this cell's album by passing in the indexPath.row to the subscript method for an array of type Album[] + let album = self.albums[indexPath.row] cell.text = album.title cell.image = UIImage(named: "Blank52") @@ -78,24 +68,24 @@ class SearchResultsViewController: UIViewController,/* UITableViewDataSource, UI // Grab the artworkUrl60 key to get an image URL for the app's thumbnail //var urlString: NSString = rowData["artworkUrl60"] as NSString - var urlString = album.thumbnailImageURL + let urlString = album.thumbnailImageURL // Check our image cache for the existing key. This is just a dictionary of UIImages - var image: UIImage? = self.imageCache.valueForKey(urlString) as? UIImage + var image: UIImage? = self.imageCache[urlString!] if( !image? ) { // If the image does not exist, we need to download it - var imgURL: NSURL = NSURL(string: urlString) + let imgURL: NSURL = NSURL(string: urlString) // Download an NSData representation of the image at the URL - var request: NSURLRequest = NSURLRequest(URL: imgURL) - var urlConnection: NSURLConnection = NSURLConnection(request: request, delegate: self) + let request: NSURLRequest = NSURLRequest(URL: imgURL) + let urlConnection: NSURLConnection = NSURLConnection(request: request, delegate: self) NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue(), completionHandler: {(response: NSURLResponse!,data: NSData!,error: NSError!) -> Void in if !error? { image = UIImage(data: data) // Store the image in to our cache - self.imageCache.setValue(image, forKey: urlString) + self.imageCache[urlString!] = image // Sometimes this request takes a while, and it's possible that a cell could be re-used before the art is done loading. // Let's explicitly call the cellForRowAtIndexPath method of our tableView to make sure the cell is not nil, and therefore still showing onscreen. @@ -125,7 +115,7 @@ class SearchResultsViewController: UIViewController,/* UITableViewDataSource, UI // Store the results in our table data array if results.count>0 { - var allResults: NSDictionary[] = results["results"] as NSDictionary[] + let allResults: NSDictionary[] = results["results"] as NSDictionary[] // var swiftResultArray: NSDictionary[] = allResults @@ -152,10 +142,9 @@ class SearchResultsViewController: UIViewController,/* UITableViewDataSource, UI } } - var thumbnailURL: String? = result["artworkUrl60"] as? String - var imageURL: String? = result["artworkUrl100"] as? String - - var artistURL: String? = result["artistViewUrl"] as? String + let thumbnailURL: String? = result["artworkUrl60"] as? String + let imageURL: String? = result["artworkUrl100"] as? String + let artistURL: String? = result["artistViewUrl"] as? String var itemURL: String? = result["collectionViewUrl"] as? String if !itemURL? { From c6e9e3284b6ec174dd3043518dc234ed07dc9b5f Mon Sep 17 00:00:00 2001 From: Jameson Quave Date: Fri, 6 Jun 2014 09:40:48 -0500 Subject: [PATCH 16/19] Push details controller --- TestSwift/APIController.swift | 6 ++++-- TestSwift/Base.lproj/Main.storyboard | 4 ++-- TestSwift/Classes/DetailsViewController.swift | 9 ++++----- TestSwift/SearchResultsViewController.swift | 11 +++++++---- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/TestSwift/APIController.swift b/TestSwift/APIController.swift index f4b677c..b6b343c 100644 --- a/TestSwift/APIController.swift +++ b/TestSwift/APIController.swift @@ -6,17 +6,19 @@ // Copyright (c) 2014 JQ Software LLC. All rights reserved. // -import UIKit +import Foundation protocol APIControllerProtocol { func didRecieveAPIResults(results: NSDictionary) } -class APIController: NSObject { +class APIController { let data: NSMutableData = NSMutableData() var delegate: APIControllerProtocol? + init(){} + func searchItunesFor(searchTerm: String) { // The iTunes API wants multiple terms separated by + symbols, so replace spaces with + signs diff --git a/TestSwift/Base.lproj/Main.storyboard b/TestSwift/Base.lproj/Main.storyboard index 76ff296..04e4d80 100644 --- a/TestSwift/Base.lproj/Main.storyboard +++ b/TestSwift/Base.lproj/Main.storyboard @@ -62,10 +62,10 @@ - + - + diff --git a/TestSwift/Classes/DetailsViewController.swift b/TestSwift/Classes/DetailsViewController.swift index afdc27d..6098407 100644 --- a/TestSwift/Classes/DetailsViewController.swift +++ b/TestSwift/Classes/DetailsViewController.swift @@ -11,12 +11,11 @@ import UIKit class DetailsViewController: UIViewController { var detailInfo: NSDictionary? - - init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) { - super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) - // Custom initialization + + init(coder aDecoder: NSCoder!) { + super.init(coder: aDecoder) } - + override func viewDidLoad() { super.viewDidLoad() diff --git a/TestSwift/SearchResultsViewController.swift b/TestSwift/SearchResultsViewController.swift index e8c6207..a513fdf 100644 --- a/TestSwift/SearchResultsViewController.swift +++ b/TestSwift/SearchResultsViewController.swift @@ -21,14 +21,17 @@ class SearchResultsViewController: UIViewController,/* UITableViewDataSource, UI override func viewDidLoad() { super.viewDidLoad() - api.delegate = self + self.api.delegate = self UIApplication.sharedApplication().networkActivityIndicatorVisible = true api.searchItunesFor("Bob Dylan"); } override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject) { - - + var detailsViewController: DetailsViewController = segue.destinationViewController as DetailsViewController + } + + /* + if segue.identifier == "Details" { //var detailsViewController: DetailsViewController? = segue.destinationViewController! as? DetailsViewController @@ -44,7 +47,7 @@ class SearchResultsViewController: UIViewController,/* UITableViewDataSource, UI detailsViewController.detailInfo = selectedAppDetails*/ } - } + }*/ func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int { return albums.count From 69e1ad70e178362fef31adce518aa6e5fc685983 Mon Sep 17 00:00:00 2001 From: Jameson Quave Date: Fri, 6 Jun 2014 09:45:42 -0500 Subject: [PATCH 17/19] Sizes class for iPhone on detail view --- TestSwift/Base.lproj/Main.storyboard | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/TestSwift/Base.lproj/Main.storyboard b/TestSwift/Base.lproj/Main.storyboard index 04e4d80..111d6ef 100644 --- a/TestSwift/Base.lproj/Main.storyboard +++ b/TestSwift/Base.lproj/Main.storyboard @@ -44,6 +44,9 @@ + + + @@ -79,6 +82,9 @@ + + + From 67fad2c70d5afeb1f15bbfaa01ffd7ad09e2b8f0 Mon Sep 17 00:00:00 2001 From: Jameson Quave Date: Fri, 6 Jun 2014 09:48:43 -0500 Subject: [PATCH 18/19] Use album class --- TestSwift/Classes/DetailsViewController.swift | 2 +- TestSwift/SearchResultsViewController.swift | 40 +++++++++---------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/TestSwift/Classes/DetailsViewController.swift b/TestSwift/Classes/DetailsViewController.swift index afdc27d..60de353 100644 --- a/TestSwift/Classes/DetailsViewController.swift +++ b/TestSwift/Classes/DetailsViewController.swift @@ -10,7 +10,7 @@ import UIKit class DetailsViewController: UIViewController { - var detailInfo: NSDictionary? + var albumInfo: Album? init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) { super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) diff --git a/TestSwift/SearchResultsViewController.swift b/TestSwift/SearchResultsViewController.swift index e8c6207..9d2e721 100644 --- a/TestSwift/SearchResultsViewController.swift +++ b/TestSwift/SearchResultsViewController.swift @@ -14,6 +14,7 @@ class SearchResultsViewController: UIViewController,/* UITableViewDataSource, UI var api: APIController = APIController() @IBOutlet var appsTableView : UITableView + var selectedAlbum: Album? var albums: Album[] = [] //var imageCache = NSMutableDictionary() @@ -26,26 +27,6 @@ class SearchResultsViewController: UIViewController,/* UITableViewDataSource, UI api.searchItunesFor("Bob Dylan"); } - override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject) { - - - if segue.identifier == "Details" { - //var detailsViewController: DetailsViewController? = segue.destinationViewController! as? DetailsViewController - - var destinationViewController: UIViewController = segue.destinationViewController as UIViewController - - // var detailsViewController: DetailsViewController = destinationViewController as DetailsViewController - - - //var destinationViewController: UIViewController! = segue.destinationViewController as UIViewController! - //var detailsViewController: DetailsViewController = destinationViewController as DetailsViewController -/* var selectedIndexPathRow = appsTableView.indexPathForSelectedRow().row - var selectedAppDetails: NSDictionary = self.tableData[selectedIndexPathRow] as NSDictionary - - detailsViewController.detailInfo = selectedAppDetails*/ - } - } - func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int { return albums.count } @@ -165,6 +146,25 @@ class SearchResultsViewController: UIViewController,/* UITableViewDataSource, UI func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!) { // Get the album for this row var album = albums[indexPath.row] + self.selectedAlbum = album + + var storyboard = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle()) +// var viewController: UIViewController = storyboard.instantiateViewControllerWithIdentifier("Details") as UIViewController + + let detailsVC = self.storyboard.instantiateViewControllerWithIdentifier("Details") as DetailsViewController + self.navigationController.pushViewController(detailsVC, animated: true) + + // self.navigationController.pushViewController(DetailsViewController(nibName: nil, bundle: nil), animated: true) + /* + let detailsVC: DetailsViewController? = viewController as? DetailsViewController + if detailsVC? { + //detailsVC?.albumInfo = self.selectedAlbum + detailsVC!.albumInfo = self.selectedAlbum + + println("Made detailsVC") + } +// detailsVC.albumInfo = self.selectedAlbum + */ } } From 770928834773ccd69cc2dca6d7bf177e619ad844 Mon Sep 17 00:00:00 2001 From: Jameson Quave Date: Fri, 6 Jun 2014 13:19:05 -0500 Subject: [PATCH 19/19] Part 6 --- .../xcdebugger/Breakpoints_v2.xcbkptlist | 115 ------------------ TestSwift/APIController.swift | 6 +- TestSwift/Base.lproj/Main.storyboard | 56 ++++++++- TestSwift/Classes/Album.swift | 12 +- TestSwift/Classes/DetailsViewController.swift | 16 +-- TestSwift/SearchResultsViewController.swift | 66 ++-------- 6 files changed, 78 insertions(+), 193 deletions(-) delete mode 100644 TestSwift.xcodeproj/xcuserdata/jquave.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist diff --git a/TestSwift.xcodeproj/xcuserdata/jquave.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/TestSwift.xcodeproj/xcuserdata/jquave.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist deleted file mode 100644 index bbdc787..0000000 --- a/TestSwift.xcodeproj/xcuserdata/jquave.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ /dev/null @@ -1,115 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/TestSwift/APIController.swift b/TestSwift/APIController.swift index b6b343c..e880383 100644 --- a/TestSwift/APIController.swift +++ b/TestSwift/APIController.swift @@ -14,10 +14,11 @@ protocol APIControllerProtocol { class APIController { - let data: NSMutableData = NSMutableData() var delegate: APIControllerProtocol? - init(){} + init(delegate: APIControllerProtocol?) { + self.delegate = delegate + } func searchItunesFor(searchTerm: String) { @@ -42,6 +43,7 @@ class APIController { println("HTTP Error: \(error?.localizedDescription)") } else { + println("Results recieved") self.delegate?.didRecieveAPIResults(jsonResult) } } diff --git a/TestSwift/Base.lproj/Main.storyboard b/TestSwift/Base.lproj/Main.storyboard index 111d6ef..242d49c 100644 --- a/TestSwift/Base.lproj/Main.storyboard +++ b/TestSwift/Base.lproj/Main.storyboard @@ -1,6 +1,7 @@ + @@ -63,12 +64,12 @@ - + - + @@ -79,22 +80,67 @@ + + + + + + + + + + + Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda. + + + + + + + + + + + + + + + + + + + + + + + + + + - + diff --git a/TestSwift/Classes/Album.swift b/TestSwift/Classes/Album.swift index 7666b0c..0c52641 100644 --- a/TestSwift/Classes/Album.swift +++ b/TestSwift/Classes/Album.swift @@ -6,19 +6,16 @@ // Copyright (c) 2014 JQ Software LLC. All rights reserved. // -import UIKit - -class Album: NSObject { +class Album { - var title: String = "N/A" - var price: String = "N/A" + var title: String? + var price: String? var thumbnailImageURL: String? var largeImageURL: String? var itemURL: String? var artistURL: String? - - init(name: String, price: String, thumbnailImageURL: String, largeImageURL: String, itemURL: String, artistURL: String) { + init(name: String!, price: String!, thumbnailImageURL: String!, largeImageURL: String!, itemURL: String!, artistURL: String!) { self.title = name self.price = price self.thumbnailImageURL = thumbnailImageURL @@ -26,5 +23,4 @@ class Album: NSObject { self.itemURL = itemURL self.artistURL = artistURL } - } diff --git a/TestSwift/Classes/DetailsViewController.swift b/TestSwift/Classes/DetailsViewController.swift index 6098407..2782737 100644 --- a/TestSwift/Classes/DetailsViewController.swift +++ b/TestSwift/Classes/DetailsViewController.swift @@ -10,7 +10,12 @@ import UIKit class DetailsViewController: UIViewController { - var detailInfo: NSDictionary? + @IBOutlet var albumCover : UIImageView + @IBOutlet var titleLabel : UILabel + @IBOutlet var detailsTextView : UITextView + @IBOutlet var openButton : UIButton + + var album: Album? init(coder aDecoder: NSCoder!) { super.init(coder: aDecoder) @@ -18,13 +23,8 @@ class DetailsViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - - // Do any additional setup after loading the view. - } - - override func didReceiveMemoryWarning() { - super.didReceiveMemoryWarning() - // Dispose of any resources that can be recreated. + titleLabel.text = self.album?.title + albumCover.image = UIImage(data: NSData(contentsOfURL: NSURL(string: self.album?.largeImageURL))) } } diff --git a/TestSwift/SearchResultsViewController.swift b/TestSwift/SearchResultsViewController.swift index d436c79..4fb9912 100644 --- a/TestSwift/SearchResultsViewController.swift +++ b/TestSwift/SearchResultsViewController.swift @@ -8,48 +8,34 @@ import UIKit -class SearchResultsViewController: UIViewController,/* UITableViewDataSource, UITableViewDelegate, */APIControllerProtocol { +class SearchResultsViewController: UIViewController, UITableViewDataSource, UITableViewDelegate, APIControllerProtocol { let kCellIdentifier: String = "SearchResultCell" - var api: APIController = APIController() + var api: APIController? + @IBOutlet var appsTableView : UITableView - var selectedAlbum: Album? + // var selectedAlbum: Album? var albums: Album[] = [] - //var imageCache = NSMutableDictionary() var imageCache = Dictionary() override func viewDidLoad() { super.viewDidLoad() - self.api.delegate = self + self.api = APIController(delegate: self) + UIApplication.sharedApplication().networkActivityIndicatorVisible = true - api.searchItunesFor("Bob Dylan"); + println("Search") + self.api!.searchItunesFor("Bob Dylan"); } override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject) { var detailsViewController: DetailsViewController = segue.destinationViewController as DetailsViewController + var albumIndex = appsTableView.indexPathForSelectedRow().row + var selectedAlbum = self.albums[albumIndex] + detailsViewController.album = selectedAlbum } - /* - - if segue.identifier == "Details" { - //var detailsViewController: DetailsViewController? = segue.destinationViewController! as? DetailsViewController - - var destinationViewController: UIViewController = segue.destinationViewController as UIViewController - - // var detailsViewController: DetailsViewController = destinationViewController as DetailsViewController - - - //var destinationViewController: UIViewController! = segue.destinationViewController as UIViewController! - //var detailsViewController: DetailsViewController = destinationViewController as DetailsViewController -/* var selectedIndexPathRow = appsTableView.indexPathForSelectedRow().row - var selectedAppDetails: NSDictionary = self.tableData[selectedIndexPathRow] as NSDictionary - - detailsViewController.detailInfo = selectedAppDetails*/ - } - }*/ - func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int { return albums.count } @@ -61,10 +47,8 @@ class SearchResultsViewController: UIViewController,/* UITableViewDataSource, UI // Find this cell's album by passing in the indexPath.row to the subscript method for an array of type Album[] let album = self.albums[indexPath.row] - cell.text = album.title cell.image = UIImage(named: "Blank52") - cell.detailTextLabel.text = album.price dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), { @@ -120,8 +104,6 @@ class SearchResultsViewController: UIViewController,/* UITableViewDataSource, UI if results.count>0 { let allResults: NSDictionary[] = results["results"] as NSDictionary[] - - // var swiftResultArray: NSDictionary[] = allResults // Sometimes iTunes returns a collection, not a track, so we check both for the 'name' for result: NSDictionary in allResults { @@ -137,7 +119,6 @@ class SearchResultsViewController: UIViewController,/* UITableViewDataSource, UI price = result["collectionPrice"] as? String if !price? { var priceFloat: Float? = result["collectionPrice"] as? Float - println(priceFloat) var nf: NSNumberFormatter = NSNumberFormatter() nf.maximumFractionDigits = 2; if priceFloat? { @@ -156,7 +137,6 @@ class SearchResultsViewController: UIViewController,/* UITableViewDataSource, UI } var newAlbum = Album(name: name!, price: price!, thumbnailImageURL: thumbnailURL!, largeImageURL: imageURL!, itemURL: itemURL!, artistURL: artistURL!) - albums.append(newAlbum) } @@ -166,30 +146,6 @@ class SearchResultsViewController: UIViewController,/* UITableViewDataSource, UI } } - func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!) { - // Get the album for this row - var album = albums[indexPath.row] - self.selectedAlbum = album - - var storyboard = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle()) -// var viewController: UIViewController = storyboard.instantiateViewControllerWithIdentifier("Details") as UIViewController - - let detailsVC = self.storyboard.instantiateViewControllerWithIdentifier("Details") as DetailsViewController - self.navigationController.pushViewController(detailsVC, animated: true) - - // self.navigationController.pushViewController(DetailsViewController(nibName: nil, bundle: nil), animated: true) - /* - let detailsVC: DetailsViewController? = viewController as? DetailsViewController - if detailsVC? { - //detailsVC?.albumInfo = self.selectedAlbum - detailsVC!.albumInfo = self.selectedAlbum - - println("Made detailsVC") - } -// detailsVC.albumInfo = self.selectedAlbum - */ - } - }