Skip to content
This repository has been archived by the owner on May 23, 2022. It is now read-only.

Commit

Permalink
Merge pull request #43 from morizotter/morizotter/xcode8-gm
Browse files Browse the repository at this point in the history
Update to latest syntax
  • Loading branch information
morizotter committed Sep 18, 2016
2 parents 7ce667c + 51ec9ea commit 0a2ab98
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 100 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ DerivedData
# Carthage/Checkouts

Carthage/Build

.DS_Store
12 changes: 6 additions & 6 deletions Demo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,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:.
}

Expand Down
84 changes: 42 additions & 42 deletions Demo/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,77 +13,77 @@ class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()

navigationController?.navigationBarHidden = true
let tapRecognizer = UITapGestureRecognizer(target: self, action: "upAllDrops:")
navigationController?.isNavigationBarHidden = true
let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(ViewController.upAllDrops(_:)))
view.addGestureRecognizer(tapRecognizer)
}

@IBAction func showStatesAlert(sender: AnyObject) {
let defaultAction = UIAlertAction(title: "Default", style: .Default) { [unowned self] action -> Void in
@IBAction func showStatesAlert(_ sender: AnyObject) {
let defaultAction = UIAlertAction(title: "Default", style: .default) { [unowned self] action -> Void in
Drop.down(self.sampleText())
}
let infoAction = UIAlertAction(title: "Info", style: .Default) { [unowned self] action -> Void in
Drop.down(self.sampleText(), state: .Info)
let infoAction = UIAlertAction(title: "Info", style: .default) { _ in
Drop.down(self.sampleText(), state: .info)
}
let successAction = UIAlertAction(title: "Success", style: .Default) { [unowned self] action -> Void in
Drop.down(self.sampleText(), state: .Success)
let successAction = UIAlertAction(title: "Success", style: .default) { _ in
Drop.down(self.sampleText(), state: .success)
}
let warningAction = UIAlertAction(title: "Warning", style: .Default) { [unowned self] action -> Void in
Drop.down(self.sampleText(), state: .Warning)
let warningAction = UIAlertAction(title: "Warning", style: .default) { _ in
Drop.down(self.sampleText(), state: .warning)
}
let errorAction = UIAlertAction(title: "Error", style: .Default) { [unowned self] action -> Void in
Drop.down(self.sampleText(), state: .Error)
let errorAction = UIAlertAction(title: "Error", style: .default) { _ in
Drop.down(self.sampleText(), state: .error)
}
let colorAction = UIAlertAction(title: "Custom color", style: .Default) { [unowned self] action -> Void in
let colorAction = UIAlertAction(title: "Custom color", style: .default) { _ in
let r = CGFloat(arc4random_uniform(256))
let g = CGFloat(arc4random_uniform(256))
let b = CGFloat(arc4random_uniform(256))
let color = UIColor(red: r/255.0, green: g/255.0, blue: b/255.0, alpha: 1.0)
Drop.down(self.sampleText(), state: .Color(color))
Drop.down(self.sampleText(), state: .color(color))
}
let actionableAction = UIAlertAction(title: "Action", style: .Default) { [unowned self] action -> Void in
let actionableAction = UIAlertAction(title: "Action", style: .default) { [unowned self] action -> Void in
Drop.down(self.sampleText()) {
let action = UIAlertAction(title: "OK", style: .Default, handler: nil)
let controller = UIAlertController(title: "Action", message: "Action fired!", preferredStyle: .Alert)
let action = UIAlertAction(title: "OK", style: .default, handler: nil)
let controller = UIAlertController(title: "Action", message: "Action fired!", preferredStyle: .alert)
controller.addAction(action)
self.presentViewController(controller, animated: true, completion: nil)
self.present(controller, animated: true, completion: nil)
}
}
let blurAction = UIAlertAction(title: "Blur", style: .Default) { [unowned self] action -> Void in
Drop.down(self.sampleText(), state: .Blur(.Light))
let blurAction = UIAlertAction(title: "Blur", style: .default) { _ in
Drop.down(self.sampleText(), state: .blur(.light))
}
let customAction = UIAlertAction(title: "Custom", style: .Default) { [unowned self] action -> Void in
let customAction = UIAlertAction(title: "Custom", style: .default) { _ in
enum Custom: DropStatable {
case BlackGreen
case blackGreen
var backgroundColor: UIColor? {
switch self {
case .BlackGreen: return .blackColor()
case .blackGreen: return .black
}
}
var font: UIFont? {
switch self {
case .BlackGreen: return UIFont(name: "HelveticaNeue-Light", size: 24.0)
case .blackGreen: return UIFont(name: "HelveticaNeue-Light", size: 24.0)
}
}
var textColor: UIColor? {
switch self {
case .BlackGreen: return .greenColor()
case .blackGreen: return .green
}
}
var blurEffect: UIBlurEffect? {
switch self {
case .BlackGreen: return nil
case .blackGreen: return nil
}
}
}
Drop.down(self.sampleText(), state: Custom.BlackGreen)
Drop.down(self.sampleText(), state: Custom.blackGreen)
}
let durationAction = UIAlertAction(title: "Duration", style: .Default) { [unowned self] action -> Void in
let durationAction = UIAlertAction(title: "Duration", style: .default) { [unowned self] action -> Void in
self.showDurationAlert()
}
let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel, handler: nil)
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)

let controller = UIAlertController(title: "Samples", message: "Select to show drop down message.", preferredStyle: .ActionSheet)
let controller = UIAlertController(title: "Samples", message: "Select to show drop down message.", preferredStyle: .actionSheet)
for action in [defaultAction, infoAction, successAction, warningAction, errorAction, colorAction, actionableAction, blurAction, customAction, durationAction, cancelAction] {
controller.addAction(action)
}
Expand All @@ -93,33 +93,33 @@ class ViewController: UIViewController {
func showDurationAlert() {
let durations = [0.5, 1.0, 2.0, 4.0, 6.0, 10.0, 20.0]
let actions = durations.map { seconds in
return UIAlertAction(title: "\(seconds)", style: .Default) { [unowned self] action -> Void in
Drop.down(self.sampleText(), state: .Default, duration: seconds)
return UIAlertAction(title: "\(seconds)", style: .default) { _ in
Drop.down(self.sampleText(), state: .default, duration: seconds)
}
}
let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel, handler: nil)
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)

let controller = UIAlertController(title: "Duration", message: "Select to duration. Default is 4 seconds.", preferredStyle: .ActionSheet)
let controller = UIAlertController(title: "Duration", message: "Select to duration. Default is 4 seconds.", preferredStyle: .actionSheet)
for action in [cancelAction] + actions {
controller.addAction(action)
}
showAlert(controller)
}

func showAlert(controller: UIAlertController, sourceView: UIView? = nil) {
if UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiom.Pad {
func showAlert(_ controller: UIAlertController, sourceView: UIView? = nil) {
if UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiom.pad {
if let sourceView = sourceView {
let rect = sourceView.convertRect(sourceView.bounds, toView: view)
let rect = sourceView.convert(sourceView.bounds, to: view)
controller.popoverPresentationController?.sourceView = view
controller.popoverPresentationController?.sourceRect = rect
}
}

presentViewController(controller, animated: true, completion: nil)
present(controller, animated: true, completion: nil)
}

func upAllDrops(sender: AnyObject) {
if let hidden = navigationController?.navigationBarHidden {
func upAllDrops(_ sender: AnyObject) {
if let hidden = navigationController?.isNavigationBarHidden {
navigationController?.setNavigationBarHidden(!hidden, animated: true)
}

Expand All @@ -129,7 +129,7 @@ class ViewController: UIViewController {
func sampleText() -> String {
let text = "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."
let length = Int(arc4random_uniform(100)) + 10
let end = text.startIndex.advancedBy(length)
return text.substringWithRange(Range(start: text.startIndex, end: end))
let end = text.characters.index(text.startIndex, offsetBy: length)
return text.substring(with: (text.startIndex ..< end))
}
}
15 changes: 14 additions & 1 deletion SwiftyDrop.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,16 @@
attributes = {
LastSwiftMigration = 0700;
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0630;
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = MORITANAOKI;
TargetAttributes = {
908543641B3690870037B0FD = {
CreatedOnToolsVersion = 6.3.2;
LastSwiftMigration = 0800;
};
90E5BA281B35791A0075B777 = {
CreatedOnToolsVersion = 6.3.2;
LastSwiftMigration = 0800;
};
};
};
Expand Down Expand Up @@ -253,6 +255,7 @@
908543791B3690870037B0FD /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
Expand All @@ -269,6 +272,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "--PRODUCT-BUNDLE-IDENTIFIER-";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand All @@ -277,6 +281,7 @@
9085437A1B3690870037B0FD /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
Expand All @@ -289,6 +294,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "--PRODUCT-BUNDLE-IDENTIFIER-";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand All @@ -307,8 +313,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand Down Expand Up @@ -353,8 +361,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand All @@ -373,6 +383,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
Expand All @@ -394,6 +405,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.molabo.SwiftyDrop;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -409,6 +421,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.molabo.SwiftyDrop;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand Down
10 changes: 5 additions & 5 deletions SwiftyDrop.xcodeproj/xcshareddata/xcschemes/SwiftyDrop.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -37,10 +37,10 @@
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -66,11 +66,11 @@
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
Expand All @@ -88,10 +88,10 @@
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
Expand Down
Loading

0 comments on commit 0a2ab98

Please sign in to comment.