Skip to content

Commit

Permalink
Migrate to Swift 4
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesrisberg committed Mar 30, 2018
1 parent 0158883 commit 390523e
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 20 deletions.
16 changes: 10 additions & 6 deletions Emojr.xcodeproj/project.pbxproj
Expand Up @@ -526,11 +526,11 @@
1546D3961CA61A5100D8ECC5 = {
CreatedOnToolsVersion = 7.2.1;
DevelopmentTeam = M2JNHSR23U;
LastSwiftMigration = 0810;
LastSwiftMigration = 0920;
};
1589F8941D27556600451912 = {
CreatedOnToolsVersion = 7.3.1;
LastSwiftMigration = 0810;
LastSwiftMigration = 0920;
TestTargetID = 1546D3961CA61A5100D8ECC5;
};
};
Expand Down Expand Up @@ -906,7 +906,8 @@
PROVISIONING_PROFILE = "";
SWIFT_OBJC_BRIDGING_HEADER = "Emojr-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -931,7 +932,8 @@
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
SWIFT_OBJC_BRIDGING_HEADER = "Emojr-Bridging-Header.h";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -946,7 +948,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.josephpecoraro.EmojrTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Emojr.app/Emojr";
};
name = Debug;
Expand All @@ -962,7 +965,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.josephpecoraro.EmojrTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Emojr.app/Emojr";
};
name = Release;
Expand Down
2 changes: 1 addition & 1 deletion Emojr/AccountViewController.swift
Expand Up @@ -16,7 +16,7 @@ extension UILabel {
let style = NSMutableParagraphStyle()
style.lineSpacing = height

string.addAttribute(NSParagraphStyleAttributeName,
string.addAttribute(NSAttributedStringKey.paragraphStyle,
value: style,
range: NSRange(location: 0, length: text.characters.count))

Expand Down
4 changes: 2 additions & 2 deletions Emojr/DiscoverViewController.swift
Expand Up @@ -13,7 +13,7 @@ class DiscoverViewController: TimelineViewController {
private lazy var searchButton: UIBarButtonItem = {
let buttonImage = #imageLiteral(resourceName: "searchEmoji").withRenderingMode(.alwaysOriginal)
let button = UIBarButtonItem(image: buttonImage, style: .plain, target: self, action: #selector(searchButtonTapped))
button.setTitleTextAttributes([NSFontAttributeName : UIFont.systemFont(ofSize: 32)], for: UIControlState())
button.setTitleTextAttributes([NSAttributedStringKey.font : UIFont.systemFont(ofSize: 32)], for: UIControlState())

return button
}()
Expand All @@ -34,7 +34,7 @@ class DiscoverViewController: TimelineViewController {

// MARK: - Action

func searchButtonTapped(sender: UIBarButtonItem) {
@objc func searchButtonTapped(sender: UIBarButtonItem) {
if User.sharedInstance.isLoggedIn {
let addUserVC = AddUsersViewController()
self.navigationController?.pushViewController(addUserVC, animated: true)
Expand Down
2 changes: 1 addition & 1 deletion Emojr/EmojiSlotMachine.swift
Expand Up @@ -66,7 +66,7 @@ class EmojiSlotMachine: UIView {
label.text = emojis[randomNumba]
}

func randomizeLabels() {
@objc func randomizeLabels() {
for label in emojiStackView.arrangedSubviews {
if let label = label as? UILabel {
randomize(label: label)
Expand Down
2 changes: 1 addition & 1 deletion Emojr/LoginManager.swift
Expand Up @@ -144,7 +144,7 @@ class LoginManager: NSObject {
navController.navigationBar.barTintColor = blue
navController.navigationBar.tintColor = UIColor.white

navController.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName : UIColor.white]
navController.navigationBar.titleTextAttributes = [NSAttributedStringKey.foregroundColor : UIColor.white]

navController.navigationBar.isTranslucent = false
}
Expand Down
12 changes: 6 additions & 6 deletions Emojr/TimelineViewController.swift
Expand Up @@ -99,7 +99,7 @@ class TimelineViewController: UIViewController {
} else {
let buttonImage = #imageLiteral(resourceName: "writeEmoji").withRenderingMode(.alwaysOriginal)
let postButton = UIBarButtonItem(image: buttonImage, style: .plain, target: self, action: #selector(postButtonTapped))
postButton.setTitleTextAttributes([NSFontAttributeName : UIFont.systemFont(ofSize: 32)], for: UIControlState())
postButton.setTitleTextAttributes([NSAttributedStringKey.font : UIFont.systemFont(ofSize: 32)], for: UIControlState())

return postButton
}
Expand Down Expand Up @@ -166,7 +166,7 @@ class TimelineViewController: UIViewController {
noDataView?.removeFromSuperview()
}

func refreshData() {
@objc func refreshData() {
tableDataSource.getFirstPage()
}

Expand Down Expand Up @@ -215,7 +215,7 @@ class TimelineViewController: UIViewController {
})
}

func dismissPostForm() {
@objc func dismissPostForm() {
UIView.animate(withDuration: 0.2,
delay: 0,
usingSpringWithDamping: 1,
Expand Down Expand Up @@ -312,15 +312,15 @@ extension TimelineViewController {
navigationItem.rightBarButtonItem = rightBarButtonItem()
}

func followUser() {
@objc func followUser() {
switch type {
case .user(let user):
followUserManager.startFollowing(user: user, completionBlock: { _ in self.updateFollowButton() })
default: break
}
}

func stopFollowingUser() {
@objc func stopFollowingUser() {
switch type {
case .user(let user):
followUserManager.askToStopFollowingUser(user, presentingViewController: self, completionBlock: { _ in self.updateFollowButton() })
Expand All @@ -333,7 +333,7 @@ extension TimelineViewController {
// MARK: - Long Tap Gesture

extension TimelineViewController {
func longTapOnCell(_ sender: UILongPressGestureRecognizer) {
@objc func longTapOnCell(_ sender: UILongPressGestureRecognizer) {
if sender.state == .began {
let location = sender.location(in: self.timelineTableView)
let indexPath = self.timelineTableView.indexPathForRow(at: location)
Expand Down
6 changes: 3 additions & 3 deletions Emojr/UserListViewController.swift
Expand Up @@ -51,7 +51,7 @@ class UserListViewController: UIViewController {

override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
self.navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName : UIColor.white]
self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedStringKey.foregroundColor : UIColor.white]
}

func rightBarButtonItem() -> UIBarButtonItem? {
Expand All @@ -75,7 +75,7 @@ class UserListViewController: UIViewController {
tableView.register(UINib(nibName: "UserTableViewCell", bundle:nil), forCellReuseIdentifier: UserCellIdentifier)
}

func refreshData() {
@objc func refreshData() {
refreshControl.beginRefreshing()

networkFacade.getUsers(completionBlock: userResponseHandler)
Expand Down Expand Up @@ -104,7 +104,7 @@ class UserListViewController: UIViewController {
}
}

func navigateToAddBySearch() {
@objc func navigateToAddBySearch() {
self.navigationController?.pushViewController(AddUsersViewController(), animated: true)
}

Expand Down

0 comments on commit 390523e

Please sign in to comment.