Skip to content

Commit d41f9a1

Browse files
authored
Merge pull request #135 from zkrige/master
Swift 4 updates
2 parents 934293e + 0e1bd3a commit d41f9a1

File tree

4 files changed

+27
-12
lines changed

4 files changed

+27
-12
lines changed

Demo/Demo.xcodeproj/project.pbxproj

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@
208208
attributes = {
209209
LastSwiftMigration = 0700;
210210
LastSwiftUpdateCheck = 0700;
211-
LastUpgradeCheck = 0800;
211+
LastUpgradeCheck = 0900;
212212
ORGANIZATIONNAME = "PHAM BA THO";
213213
TargetAttributes = {
214214
2E44D6A31B4C326300C9C49E = {
@@ -344,14 +344,20 @@
344344
CLANG_CXX_LIBRARY = "libc++";
345345
CLANG_ENABLE_MODULES = YES;
346346
CLANG_ENABLE_OBJC_ARC = YES;
347+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
347348
CLANG_WARN_BOOL_CONVERSION = YES;
349+
CLANG_WARN_COMMA = YES;
348350
CLANG_WARN_CONSTANT_CONVERSION = YES;
349351
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
350352
CLANG_WARN_EMPTY_BODY = YES;
351353
CLANG_WARN_ENUM_CONVERSION = YES;
352354
CLANG_WARN_INFINITE_RECURSION = YES;
353355
CLANG_WARN_INT_CONVERSION = YES;
356+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
357+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
354358
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
359+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
360+
CLANG_WARN_STRICT_PROTOTYPES = YES;
355361
CLANG_WARN_SUSPICIOUS_MOVE = YES;
356362
CLANG_WARN_UNREACHABLE_CODE = YES;
357363
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -391,14 +397,20 @@
391397
CLANG_CXX_LIBRARY = "libc++";
392398
CLANG_ENABLE_MODULES = YES;
393399
CLANG_ENABLE_OBJC_ARC = YES;
400+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
394401
CLANG_WARN_BOOL_CONVERSION = YES;
402+
CLANG_WARN_COMMA = YES;
395403
CLANG_WARN_CONSTANT_CONVERSION = YES;
396404
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
397405
CLANG_WARN_EMPTY_BODY = YES;
398406
CLANG_WARN_ENUM_CONVERSION = YES;
399407
CLANG_WARN_INFINITE_RECURSION = YES;
400408
CLANG_WARN_INT_CONVERSION = YES;
409+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
410+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
401411
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
412+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
413+
CLANG_WARN_STRICT_PROTOTYPES = YES;
402414
CLANG_WARN_SUSPICIOUS_MOVE = YES;
403415
CLANG_WARN_UNREACHABLE_CODE = YES;
404416
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -427,12 +439,13 @@
427439
isa = XCBuildConfiguration;
428440
buildSettings = {
429441
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
442+
DEVELOPMENT_TEAM = 86P6ENG49D;
430443
INFOPLIST_FILE = "Demo/Supporting Files/Info.plist";
431444
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
432445
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
433446
PRODUCT_BUNDLE_IDENTIFIER = "phambatho.$(PRODUCT_NAME:rfc1034identifier)";
434447
PRODUCT_NAME = "$(TARGET_NAME)";
435-
SWIFT_VERSION = 3.0;
448+
SWIFT_VERSION = 4.0;
436449
};
437450
name = Debug;
438451
};
@@ -445,7 +458,7 @@
445458
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
446459
PRODUCT_BUNDLE_IDENTIFIER = "phambatho.$(PRODUCT_NAME:rfc1034identifier)";
447460
PRODUCT_NAME = "$(TARGET_NAME)";
448-
SWIFT_VERSION = 3.0;
461+
SWIFT_VERSION = 4.0;
449462
};
450463
name = Release;
451464
};

Demo/Demo.xcodeproj/xcshareddata/xcschemes/Demo.xcscheme

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0800"
3+
LastUpgradeVersion = "0900"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -40,6 +40,7 @@
4040
buildConfiguration = "Debug"
4141
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
4242
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
43+
language = ""
4344
shouldUseLaunchSchemeArgsEnv = "YES">
4445
<Testables>
4546
<TestableReference
@@ -69,6 +70,7 @@
6970
buildConfiguration = "Debug"
7071
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
7172
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
73+
language = ""
7274
launchStyle = "0"
7375
useCustomWorkingDirectory = "NO"
7476
ignoresPersistentStateOnLaunch = "NO"

Demo/Demo/ViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class ViewController: UIViewController {
1919
self.selectedCellLabel.text = items.first
2020
self.navigationController?.navigationBar.isTranslucent = false
2121
self.navigationController?.navigationBar.barTintColor = UIColor(red: 0.0/255.0, green:180/255.0, blue:220/255.0, alpha: 1.0)
22-
self.navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.white]
22+
self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.white]
2323

2424
// "Old" version
2525
// menuView = BTNavigationDropdownMenu(navigationController: self.navigationController, containerView: self.navigationController!.view, title: "Dropdown Menu", items: items)

Source/BTNavigationDropdownMenu.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ open class BTNavigationDropdownMenu: UIView {
4545
return self.configuration.cellHeight as NSNumber!
4646
}
4747
set(value) {
48-
self.configuration.cellHeight = CGFloat(value)
48+
self.configuration.cellHeight = CGFloat(truncating: value)
4949
}
5050
}
5151

@@ -294,7 +294,7 @@ open class BTNavigationDropdownMenu: UIView {
294294
titleToDisplay = title
295295
}
296296

297-
titleSize = (titleToDisplay as NSString).size(attributes: [NSFontAttributeName:self.configuration.navigationBarTitleFont])
297+
titleSize = (titleToDisplay as NSString).size(withAttributes: [NSAttributedStringKey.font:self.configuration.navigationBarTitleFont])
298298

299299
// Set frame
300300
let frame = CGRect(x: 0, y: 0, width: titleSize.width + (self.configuration.arrowPadding + self.configuration.arrowImage.size.width)*2, height: self.navigationController!.navigationBar.frame.height)
@@ -423,10 +423,10 @@ open class BTNavigationDropdownMenu: UIView {
423423
}
424424

425425
func setupDefaultConfiguration() {
426-
self.menuTitleColor = self.navigationController?.navigationBar.titleTextAttributes?[NSForegroundColorAttributeName] as? UIColor
426+
self.menuTitleColor = self.navigationController?.navigationBar.titleTextAttributes?[NSAttributedStringKey.foregroundColor] as? UIColor
427427
self.cellBackgroundColor = self.navigationController?.navigationBar.barTintColor
428-
self.cellSeparatorColor = self.navigationController?.navigationBar.titleTextAttributes?[NSForegroundColorAttributeName] as? UIColor
429-
self.cellTextLabelColor = self.navigationController?.navigationBar.titleTextAttributes?[NSForegroundColorAttributeName] as? UIColor
428+
self.cellSeparatorColor = self.navigationController?.navigationBar.titleTextAttributes?[NSAttributedStringKey.foregroundColor] as? UIColor
429+
self.cellTextLabelColor = self.navigationController?.navigationBar.titleTextAttributes?[NSAttributedStringKey.foregroundColor] as? UIColor
430430

431431
self.arrowTintColor = self.configuration.arrowTintColor
432432
}
@@ -473,7 +473,7 @@ open class BTNavigationDropdownMenu: UIView {
473473
)
474474
}
475475

476-
func hideMenu() {
476+
@objc func hideMenu() {
477477
// Rotate arrow
478478
self.rotateArrow()
479479

@@ -520,7 +520,7 @@ open class BTNavigationDropdownMenu: UIView {
520520
self.menuTitle.text = title
521521
}
522522

523-
func menuButtonTapped(_ sender: UIButton) {
523+
@objc func menuButtonTapped(_ sender: UIButton) {
524524
self.isShown == true ? hideMenu() : showMenu()
525525
}
526526
}

0 commit comments

Comments
 (0)