Skip to content

Commit 8014dde

Browse files
committed
Migrate to Swift 3.0
1 parent 413db8b commit 8014dde

25 files changed

Lines changed: 423 additions & 414 deletions

Example/PagingMenuControllerDemo.xcodeproj/project.pbxproj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,9 +413,11 @@
413413
TargetAttributes = {
414414
707C60DA1AFF822100BDAB0B = {
415415
CreatedOnToolsVersion = 6.3.1;
416+
LastSwiftMigration = 0800;
416417
};
417418
707C60EF1AFF822200BDAB0B = {
418419
CreatedOnToolsVersion = 6.3.1;
420+
LastSwiftMigration = 0800;
419421
TestTargetID = 707C60DA1AFF822100BDAB0B;
420422
};
421423
EC7BA3F61B524BB4007FB8A5 = {
@@ -427,6 +429,7 @@
427429
};
428430
EC96215C1C5B4F1700DA6EE6 = {
429431
CreatedOnToolsVersion = 7.2;
432+
LastSwiftMigration = 0800;
430433
TestTargetID = 707C60DA1AFF822100BDAB0B;
431434
};
432435
};
@@ -826,6 +829,7 @@
826829
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
827830
PRODUCT_BUNDLE_IDENTIFIER = "com.kitasuke.$(PRODUCT_NAME:rfc1034identifier)";
828831
PRODUCT_NAME = "$(TARGET_NAME)";
832+
SWIFT_VERSION = 3.0;
829833
TARGETED_DEVICE_FAMILY = "1,2";
830834
};
831835
name = Debug;
@@ -839,6 +843,7 @@
839843
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
840844
PRODUCT_BUNDLE_IDENTIFIER = "com.kitasuke.$(PRODUCT_NAME:rfc1034identifier)";
841845
PRODUCT_NAME = "$(TARGET_NAME)";
846+
SWIFT_VERSION = 3.0;
842847
TARGETED_DEVICE_FAMILY = "1,2";
843848
};
844849
name = Release;
@@ -860,6 +865,7 @@
860865
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
861866
PRODUCT_BUNDLE_IDENTIFIER = "com.kitasuke.$(PRODUCT_NAME:rfc1034identifier)";
862867
PRODUCT_NAME = "$(TARGET_NAME)";
868+
SWIFT_VERSION = 3.0;
863869
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PagingMenuControllerDemo.app/PagingMenuControllerDemo";
864870
};
865871
name = Debug;
@@ -877,6 +883,7 @@
877883
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
878884
PRODUCT_BUNDLE_IDENTIFIER = "com.kitasuke.$(PRODUCT_NAME:rfc1034identifier)";
879885
PRODUCT_NAME = "$(TARGET_NAME)";
886+
SWIFT_VERSION = 3.0;
880887
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PagingMenuControllerDemo.app/PagingMenuControllerDemo";
881888
};
882889
name = Release;
@@ -960,6 +967,7 @@
960967
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
961968
PRODUCT_BUNDLE_IDENTIFIER = com.kitasuke.PagingMenuControllerDemoUITests;
962969
PRODUCT_NAME = "$(TARGET_NAME)";
970+
SWIFT_VERSION = 3.0;
963971
TEST_TARGET_NAME = PagingMenuControllerDemo;
964972
USES_XCTRUNNER = YES;
965973
};
@@ -973,6 +981,7 @@
973981
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
974982
PRODUCT_BUNDLE_IDENTIFIER = com.kitasuke.PagingMenuControllerDemoUITests;
975983
PRODUCT_NAME = "$(TARGET_NAME)";
984+
SWIFT_VERSION = 3.0;
976985
TEST_TARGET_NAME = PagingMenuControllerDemo;
977986
USES_XCTRUNNER = YES;
978987
};

Example/PagingMenuControllerDemo/AppDelegate.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,30 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1414
var window: UIWindow?
1515

1616

17-
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
17+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
1818
// Override point for customization after application launch.
1919
return true
2020
}
2121

22-
func applicationWillResignActive(application: UIApplication) {
22+
func applicationWillResignActive(_ application: UIApplication) {
2323
// 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.
2424
// 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.
2525
}
2626

27-
func applicationDidEnterBackground(application: UIApplication) {
27+
func applicationDidEnterBackground(_ application: UIApplication) {
2828
// 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.
2929
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
3030
}
3131

32-
func applicationWillEnterForeground(application: UIApplication) {
32+
func applicationWillEnterForeground(_ application: UIApplication) {
3333
// 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.
3434
}
3535

36-
func applicationDidBecomeActive(application: UIApplication) {
36+
func applicationDidBecomeActive(_ application: UIApplication) {
3737
// 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.
3838
}
3939

40-
func applicationWillTerminate(application: UIApplication) {
40+
func applicationWillTerminate(_ application: UIApplication) {
4141
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
4242
}
4343

Example/PagingMenuControllerDemo/GistsViewController.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@ class GistsViewController: UITableViewController {
1313

1414
class func instantiateFromStoryboard() -> GistsViewController {
1515
let storyboard = UIStoryboard(name: "MenuViewController", bundle: nil)
16-
return storyboard.instantiateViewControllerWithIdentifier(String(self)) as! GistsViewController
16+
return storyboard.instantiateViewController(withIdentifier: String(self)) as! GistsViewController
1717
}
1818

1919
// MARK: - Lifecycle
2020

2121
override func viewDidLoad() {
2222
super.viewDidLoad()
2323

24-
let url = NSURL(string: "https://api.github.com/gists/public")
25-
let request = NSURLRequest(URL: url!)
26-
let session = NSURLSession(configuration: NSURLSessionConfiguration.defaultSessionConfiguration())
24+
let url = URL(string: "https://api.github.com/gists/public")
25+
let request = URLRequest(url: url!)
26+
let session = URLSession(configuration: URLSessionConfiguration.default())
2727

28-
let task = session.dataTaskWithRequest(request) { [weak self] data, response, error in
29-
let result = try? NSJSONSerialization.JSONObjectWithData(data!, options: .AllowFragments) as! [[String: AnyObject]]
28+
let task = session.dataTask(with: request) { [weak self] data, response, error in
29+
let result = try? JSONSerialization.jsonObject(with: data!, options: .allowFragments) as! [[String: AnyObject]]
3030
self?.gists = result ?? []
3131

32-
dispatch_async(dispatch_get_main_queue(), { () -> Void in
32+
DispatchQueue.main.async(execute: { () -> Void in
3333
self?.tableView.reloadData()
3434
})
3535
}
@@ -40,21 +40,21 @@ class GistsViewController: UITableViewController {
4040
extension GistsViewController {
4141
// MARK: - UITableViewDataSource
4242

43-
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
43+
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
4444
return gists.count
4545
}
4646

4747
// MARK: - UITableViewDelegate
4848

49-
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
50-
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath)
49+
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
50+
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
5151

52-
let gist = gists[indexPath.row]
52+
let gist = gists[(indexPath as NSIndexPath).row]
5353
cell.textLabel?.text = gist["description"] as? String
5454
return cell
5555
}
5656

57-
override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
57+
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
5858
return true
5959
}
6060
}

Example/PagingMenuControllerDemo/OrganizationsViewController.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@ class OrganizationsViewController: UITableViewController {
1313

1414
class func instantiateFromStoryboard() -> OrganizationsViewController {
1515
let storyboard = UIStoryboard(name: "MenuViewController", bundle: nil)
16-
return storyboard.instantiateViewControllerWithIdentifier(String(self)) as! OrganizationsViewController
16+
return storyboard.instantiateViewController(withIdentifier: String(self)) as! OrganizationsViewController
1717
}
1818

1919
// MARK: - Lifecycle
2020

2121
override func viewDidLoad() {
2222
super.viewDidLoad()
2323

24-
let url = NSURL(string: "https://api.github.com/organizations")
25-
let request = NSURLRequest(URL: url!)
26-
let session = NSURLSession(configuration: NSURLSessionConfiguration.defaultSessionConfiguration())
24+
let url = URL(string: "https://api.github.com/organizations")
25+
let request = URLRequest(url: url!)
26+
let session = URLSession(configuration: URLSessionConfiguration.default())
2727

28-
let task = session.dataTaskWithRequest(request) { [weak self] data, response, error in
29-
let result = try? NSJSONSerialization.JSONObjectWithData(data!, options: .AllowFragments) as! [[String: AnyObject]]
28+
let task = session.dataTask(with: request) { [weak self] data, response, error in
29+
let result = try? JSONSerialization.jsonObject(with: data!, options: .allowFragments) as! [[String: AnyObject]]
3030
self?.organizations = result ?? []
3131

32-
dispatch_async(dispatch_get_main_queue(), { () -> Void in
32+
DispatchQueue.main.async(execute: { () -> Void in
3333
self?.tableView.reloadData()
3434
})
3535
}
@@ -40,21 +40,21 @@ class OrganizationsViewController: UITableViewController {
4040
extension OrganizationsViewController {
4141
// MARK: - UITableViewDataSource
4242

43-
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
43+
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
4444
return organizations.count
4545
}
4646

4747
// MARK: - UITableViewDelegate
4848

49-
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
50-
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath)
49+
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
50+
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
5151

52-
let organization = organizations[indexPath.row]
52+
let organization = organizations[(indexPath as NSIndexPath).row]
5353
cell.textLabel?.text = organization["login"] as? String
5454
return cell
5555
}
5656

57-
override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
57+
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
5858
return true
5959
}
60-
}
60+
}

Example/PagingMenuControllerDemo/PagingMenuControllerOptions.swift

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ struct MenuItemOrganization: MenuItemViewCustomizable {}
2424

2525
struct PagingMenuOptions1: PagingMenuControllerCustomizable {
2626
var componentType: ComponentType {
27-
return .All(menuOptions: MenuOptions(), pagingControllers: pagingControllers)
27+
return .all(menuOptions: MenuOptions(), pagingControllers: pagingControllers)
2828
}
2929

3030
struct MenuOptions: MenuViewCustomizable {
3131
var displayMode: MenuDisplayMode {
32-
return .Standard(widthMode: .Flexible, centerItem: false, scrollingMode: .PagingEnabled)
32+
return .standard(widthMode: .flexible, centerItem: false, scrollingMode: .pagingEnabled)
3333
}
3434
var focusMode: MenuFocusMode {
35-
return .None
35+
return .none
3636
}
3737
var height: CGFloat {
3838
return 60
@@ -46,43 +46,43 @@ struct PagingMenuOptions1: PagingMenuControllerCustomizable {
4646
var displayMode: MenuItemDisplayMode {
4747
let title = MenuItemText(text: "Menu")
4848
let description = MenuItemText(text: String(self))
49-
return .MultilineText(title: title, description: description)
49+
return .multilineText(title: title, description: description)
5050
}
5151
}
5252
struct MenuItemRepository: MenuItemViewCustomizable {
5353
var displayMode: MenuItemDisplayMode {
5454
let title = MenuItemText(text: "Menu")
5555
let description = MenuItemText(text: String(self))
56-
return .MultilineText(title: title, description: description)
56+
return .multilineText(title: title, description: description)
5757
}
5858
}
5959
struct MenuItemGists: MenuItemViewCustomizable {
6060
var displayMode: MenuItemDisplayMode {
6161
let title = MenuItemText(text: "Menu")
6262
let description = MenuItemText(text: String(self))
63-
return .MultilineText(title: title, description: description)
63+
return .multilineText(title: title, description: description)
6464
}
6565
}
6666
struct MenuItemOrganization: MenuItemViewCustomizable {
6767
var displayMode: MenuItemDisplayMode {
6868
let title = MenuItemText(text: "Menu")
6969
let description = MenuItemText(text: String(self))
70-
return .MultilineText(title: title, description: description)
70+
return .multilineText(title: title, description: description)
7171
}
7272
}
7373
}
7474

7575
struct PagingMenuOptions2: PagingMenuControllerCustomizable {
7676
var componentType: ComponentType {
77-
return .All(menuOptions: MenuOptions(), pagingControllers: pagingControllers)
77+
return .all(menuOptions: MenuOptions(), pagingControllers: pagingControllers)
7878
}
7979
var menuControllerSet: MenuControllerSet {
80-
return .Single
80+
return .single
8181
}
8282

8383
struct MenuOptions: MenuViewCustomizable {
8484
var displayMode: MenuDisplayMode {
85-
return .SegmentedControl
85+
return .segmentedControl
8686
}
8787
var itemsOptions: [MenuItemViewCustomizable] {
8888
return [MenuItemUsers(), MenuItemRepository(), MenuItemGists(), MenuItemOrganization()]
@@ -92,15 +92,15 @@ struct PagingMenuOptions2: PagingMenuControllerCustomizable {
9292

9393
struct PagingMenuOptions3: PagingMenuControllerCustomizable {
9494
var componentType: ComponentType {
95-
return .All(menuOptions: MenuOptions(), pagingControllers: pagingControllers)
95+
return .all(menuOptions: MenuOptions(), pagingControllers: pagingControllers)
9696
}
9797
var lazyLoadingPage: LazyLoadingPage {
98-
return .Three
98+
return .three
9999
}
100100

101101
struct MenuOptions: MenuViewCustomizable {
102102
var displayMode: MenuDisplayMode {
103-
return .Infinite(widthMode: .Fixed(width: 80), scrollingMode: .ScrollEnabled)
103+
return .infinite(widthMode: .fixed(width: 80), scrollingMode: .scrollEnabled)
104104
}
105105
var itemsOptions: [MenuItemViewCustomizable] {
106106
return [MenuItemUsers(), MenuItemRepository(), MenuItemGists(), MenuItemOrganization()]
@@ -110,15 +110,15 @@ struct PagingMenuOptions3: PagingMenuControllerCustomizable {
110110

111111
struct PagingMenuOptions4: PagingMenuControllerCustomizable {
112112
var componentType: ComponentType {
113-
return .MenuView(menuOptions: MenuOptions())
113+
return .menuView(menuOptions: MenuOptions())
114114
}
115115

116116
struct MenuOptions: MenuViewCustomizable {
117117
var displayMode: MenuDisplayMode {
118-
return .SegmentedControl
118+
return .segmentedControl
119119
}
120120
var focusMode: MenuFocusMode {
121-
return .Underline(height: 3, color: UIColor.blueColor(), horizontalPadding: 10, verticalPadding: 0)
121+
return .underline(height: 3, color: UIColor.blue(), horizontalPadding: 10, verticalPadding: 0)
122122
}
123123
var itemsOptions: [MenuItemViewCustomizable] {
124124
return [MenuItemUsers(), MenuItemRepository(), MenuItemGists(), MenuItemOrganization()]
@@ -128,15 +128,15 @@ struct PagingMenuOptions4: PagingMenuControllerCustomizable {
128128

129129
struct PagingMenuOptions5: PagingMenuControllerCustomizable {
130130
var componentType: ComponentType {
131-
return .MenuView(menuOptions: MenuOptions())
131+
return .menuView(menuOptions: MenuOptions())
132132
}
133133

134134
struct MenuOptions: MenuViewCustomizable {
135135
var displayMode: MenuDisplayMode {
136-
return .Infinite(widthMode: .Flexible, scrollingMode: .PagingEnabled)
136+
return .infinite(widthMode: .flexible, scrollingMode: .pagingEnabled)
137137
}
138138
var focusMode: MenuFocusMode {
139-
return .RoundRect(radius: 12, horizontalPadding: 8, verticalPadding: 8, selectedColor: UIColor.lightGrayColor())
139+
return .roundRect(radius: 12, horizontalPadding: 8, verticalPadding: 8, selectedColor: UIColor.lightGray())
140140
}
141141
var itemsOptions: [MenuItemViewCustomizable] {
142142
return [MenuItemUsers(), MenuItemRepository(), MenuItemGists(), MenuItemOrganization()]
@@ -146,9 +146,9 @@ struct PagingMenuOptions5: PagingMenuControllerCustomizable {
146146

147147
struct PagingMenuOptions6: PagingMenuControllerCustomizable {
148148
var componentType: ComponentType {
149-
return .PagingController(pagingControllers: pagingControllers)
149+
return .pagingController(pagingControllers: pagingControllers)
150150
}
151151
var defaultPage: Int {
152152
return 1
153153
}
154-
}
154+
}

Example/PagingMenuControllerDemo/PagingMenuViewController.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ class PagingMenuViewController: UIViewController {
2525
extension PagingMenuViewController: PagingMenuControllerDelegate {
2626
// MARK: - PagingMenuControllerDelegate
2727

28-
func willMoveToPageMenuController(menuController: UIViewController, previousMenuController: UIViewController) {
28+
func willMoveToPageMenuController(_ menuController: UIViewController, previousMenuController: UIViewController) {
2929
}
3030

31-
func didMoveToPageMenuController(menuController: UIViewController, previousMenuController: UIViewController) {
31+
func didMoveToPageMenuController(_ menuController: UIViewController, previousMenuController: UIViewController) {
3232
}
3333

34-
func willMoveToMenuItemView(menuItemView: MenuItemView, previousMenuItemView: MenuItemView) {
34+
func willMoveToMenuItemView(_ menuItemView: MenuItemView, previousMenuItemView: MenuItemView) {
3535
}
3636

37-
func didMoveToMenuItemView(menuItemView: MenuItemView, previousMenuItemView: MenuItemView) {
37+
func didMoveToMenuItemView(_ menuItemView: MenuItemView, previousMenuItemView: MenuItemView) {
3838
}
39-
}
39+
}

0 commit comments

Comments
 (0)