diff --git a/Paging_Swift/Paging_Swift.xcodeproj/project.pbxproj b/Paging_Swift/Paging_Swift.xcodeproj/project.pbxproj index 4d5659d..c80cf0e 100644 --- a/Paging_Swift/Paging_Swift.xcodeproj/project.pbxproj +++ b/Paging_Swift/Paging_Swift.xcodeproj/project.pbxproj @@ -107,6 +107,8 @@ TargetAttributes = { B2A6778219FD197300B3F6DB = { CreatedOnToolsVersion = 6.1; + DevelopmentTeam = 6P8Q9Q6J62; + LastSwiftMigration = 0820; }; }; }; @@ -255,9 +257,11 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = 6P8Q9Q6J62; INFOPLIST_FILE = Paging_Swift/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; }; name = Debug; }; @@ -265,9 +269,11 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = 6P8Q9Q6J62; INFOPLIST_FILE = Paging_Swift/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; }; name = Release; }; diff --git a/Paging_Swift/Paging_Swift.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Paging_Swift/Paging_Swift.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/Paging_Swift/Paging_Swift.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Paging_Swift/Paging_Swift.xcodeproj/project.xcworkspace/xcuserdata/jek.xcuserdatad/UserInterfaceState.xcuserstate b/Paging_Swift/Paging_Swift.xcodeproj/project.xcworkspace/xcuserdata/jek.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..0ba91a2 Binary files /dev/null and b/Paging_Swift/Paging_Swift.xcodeproj/project.xcworkspace/xcuserdata/jek.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Paging_Swift/Paging_Swift.xcodeproj/xcuserdata/jek.xcuserdatad/xcschemes/Paging_Swift.xcscheme b/Paging_Swift/Paging_Swift.xcodeproj/xcuserdata/jek.xcuserdatad/xcschemes/Paging_Swift.xcscheme new file mode 100644 index 0000000..0f6fd8c --- /dev/null +++ b/Paging_Swift/Paging_Swift.xcodeproj/xcuserdata/jek.xcuserdatad/xcschemes/Paging_Swift.xcscheme @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Paging_Swift/Paging_Swift.xcodeproj/xcuserdata/jek.xcuserdatad/xcschemes/xcschememanagement.plist b/Paging_Swift/Paging_Swift.xcodeproj/xcuserdata/jek.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..186a25c --- /dev/null +++ b/Paging_Swift/Paging_Swift.xcodeproj/xcuserdata/jek.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,22 @@ + + + + + SchemeUserState + + Paging_Swift.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + B2A6778219FD197300B3F6DB + + primary + + + + + diff --git a/Paging_Swift/Paging_Swift/AppDelegate.swift b/Paging_Swift/Paging_Swift/AppDelegate.swift index e10855e..c588bf9 100644 --- a/Paging_Swift/Paging_Swift/AppDelegate.swift +++ b/Paging_Swift/Paging_Swift/AppDelegate.swift @@ -14,30 +14,30 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. return true } - func applicationWillResignActive(application: UIApplication) { + 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) { + 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) { + 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) { + 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) { + func applicationWillTerminate(_ application: UIApplication) { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } diff --git a/Paging_Swift/Paging_Swift/ViewController.swift b/Paging_Swift/Paging_Swift/ViewController.swift index 216bc18..5340a5c 100644 --- a/Paging_Swift/Paging_Swift/ViewController.swift +++ b/Paging_Swift/Paging_Swift/ViewController.swift @@ -7,14 +7,38 @@ // import UIKit +// FIXME: comparison operators with optionals were removed from the Swift Standard Libary. +// Consider refactoring the code to use the non-optional operators. +fileprivate func < (lhs: T?, rhs: T?) -> Bool { + switch (lhs, rhs) { + case let (l?, r?): + return l < r + case (nil, _?): + return true + default: + return false + } +} + +// FIXME: comparison operators with optionals were removed from the Swift Standard Libary. +// Consider refactoring the code to use the non-optional operators. +fileprivate func > (lhs: T?, rhs: T?) -> Bool { + switch (lhs, rhs) { + case let (l?, r?): + return l > r + default: + return rhs < lhs + } +} + class ViewController: UIViewController, UIPageViewControllerDataSource { // MARK: - Variables - private var pageViewController: UIPageViewController? + fileprivate var pageViewController: UIPageViewController? // Initialize it right away here - private let contentImages = ["nature_pic_1", + fileprivate let contentImages = ["nature_pic_1", "nature_pic_2", "nature_pic_3", "nature_pic_4"] @@ -26,33 +50,33 @@ class ViewController: UIViewController, UIPageViewControllerDataSource { setupPageControl() } - private func createPageViewController() { + fileprivate func createPageViewController() { - let pageController = self.storyboard!.instantiateViewControllerWithIdentifier("PageController") as! UIPageViewController + let pageController = self.storyboard!.instantiateViewController(withIdentifier: "PageController") as! UIPageViewController pageController.dataSource = self if contentImages.count > 0 { let firstController = getItemController(0)! let startingViewControllers = [firstController] - pageController.setViewControllers(startingViewControllers, direction: UIPageViewControllerNavigationDirection.Forward, animated: false, completion: nil) + pageController.setViewControllers(startingViewControllers, direction: UIPageViewControllerNavigationDirection.forward, animated: false, completion: nil) } pageViewController = pageController addChildViewController(pageViewController!) self.view.addSubview(pageViewController!.view) - pageViewController!.didMoveToParentViewController(self) + pageViewController!.didMove(toParentViewController: self) } - private func setupPageControl() { + fileprivate func setupPageControl() { let appearance = UIPageControl.appearance() - appearance.pageIndicatorTintColor = UIColor.grayColor() - appearance.currentPageIndicatorTintColor = UIColor.whiteColor() - appearance.backgroundColor = UIColor.darkGrayColor() + appearance.pageIndicatorTintColor = UIColor.gray + appearance.currentPageIndicatorTintColor = UIColor.white + appearance.backgroundColor = UIColor.darkGray } // MARK: - UIPageViewControllerDataSource - func pageViewController(pageViewController: UIPageViewController, viewControllerBeforeViewController viewController: UIViewController) -> UIViewController? { + func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? { let itemController = viewController as! PageItemController @@ -63,7 +87,7 @@ class ViewController: UIViewController, UIPageViewControllerDataSource { return nil } - func pageViewController(pageViewController: UIPageViewController, viewControllerAfterViewController viewController: UIViewController) -> UIViewController? { + func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? { let itemController = viewController as! PageItemController @@ -74,10 +98,10 @@ class ViewController: UIViewController, UIPageViewControllerDataSource { return nil } - private func getItemController(itemIndex: Int) -> PageItemController? { + fileprivate func getItemController(_ itemIndex: Int) -> PageItemController? { if itemIndex < contentImages.count { - let pageItemController = self.storyboard!.instantiateViewControllerWithIdentifier("ItemController") as! PageItemController + let pageItemController = self.storyboard!.instantiateViewController(withIdentifier: "ItemController") as! PageItemController pageItemController.itemIndex = itemIndex pageItemController.imageName = contentImages[itemIndex] return pageItemController @@ -88,11 +112,11 @@ class ViewController: UIViewController, UIPageViewControllerDataSource { // MARK: - Page Indicator - func presentationCountForPageViewController(pageViewController: UIPageViewController) -> Int { + func presentationCount(for pageViewController: UIPageViewController) -> Int { return contentImages.count } - func presentationIndexForPageViewController(pageViewController: UIPageViewController) -> Int { + func presentationIndex(for pageViewController: UIPageViewController) -> Int { return 0 }