Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
attributes = {
LastSwiftMigration = 0710;
LastSwiftUpdateCheck = 0710;
LastUpgradeCheck = 0800;
LastUpgradeCheck = 0920;
ORGANIZATIONNAME = "Daiki Okumura";
TargetAttributes = {
4F47CAAA1AE26BD100BF71E4 = {
Expand All @@ -178,6 +178,7 @@
};
4F47CABF1AE26BD100BF71E4 = {
CreatedOnToolsVersion = 6.2;
LastSwiftMigration = 0920;
TestTargetID = 4F47CAAA1AE26BD100BF71E4;
};
};
Expand Down Expand Up @@ -278,14 +279,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
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_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -325,14 +332,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
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_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -367,7 +380,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "co.devlog.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -382,7 +395,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "co.devlog.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand All @@ -403,6 +416,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "co.devlog.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DOAlertController-DEMO.app/DOAlertController-DEMO";
};
name = Debug;
Expand All @@ -419,6 +434,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "co.devlog.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DOAlertController-DEMO.app/DOAlertController-DEMO";
};
name = Release;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -627,23 +627,25 @@ open class DOAlertController : UIViewController, UITextFieldDelegate, UIViewCont
}

// Button Tapped Action
func buttonTapped(_ sender: UIButton) {
@objc func buttonTapped(_ sender: UIButton) {
sender.isSelected = true
let action = actions[sender.tag - 1] as! DOAlertAction
if (action.handler != nil) {
action.handler(action)
}
self.dismiss(animated: true, completion: nil)
self.dismiss(animated: true, completion:{
if (action.handler != nil) {
action.handler(action)
}
})
}

// Handle ContainerView tap gesture
func handleContainerViewTapGesture(_ sender: AnyObject) {
@objc func handleContainerViewTapGesture(_ sender: AnyObject) {
// cancel action
let action = actions[cancelButtonTag - 1] as! DOAlertAction
if (action.handler != nil) {
action.handler(action)
}
self.dismiss(animated: true, completion: nil)
self.dismiss(animated: true, completion:{
if (action.handler != nil) {
action.handler(action)
}
})
}

// UIColor -> UIImage
Expand All @@ -662,11 +664,11 @@ open class DOAlertController : UIViewController, UITextFieldDelegate, UIViewCont

@objc func handleAlertActionEnabledDidChangeNotification(_ notification: Notification) {
for i in 0..<buttons.count {
buttons[i].isEnabled = actions[i].enabled
buttons[i].isEnabled = (actions[i] as! DOAlertAction).enabled
}
}

func handleKeyboardWillShowNotification(_ notification: Notification) {
@objc func handleKeyboardWillShowNotification(_ notification: Notification) {
if let userInfo = notification.userInfo as? [String: NSValue],
let keyboardSize = userInfo[UIKeyboardFrameEndUserInfoKey]?.cgRectValue.size {
var _keyboardSize = keyboardSize
Expand All @@ -684,7 +686,7 @@ open class DOAlertController : UIViewController, UITextFieldDelegate, UIViewCont
}
}

func handleKeyboardWillHideNotification(_ notification: Notification) {
@objc func handleKeyboardWillHideNotification(_ notification: Notification) {
keyboardHeight = 0.0
reloadAlertViewHeight()
containerViewBottomSpaceConstraint?.constant = keyboardHeight
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ class ViewController : UITableViewController, UITextFieldDelegate {
// Create the action.
let cancelAction = DOAlertAction(title: cancelButtonTitle, style: .cancel) { action in
NSLog("The simple alert's cancel action occured.")
let systemAlertController = UIAlertController(title: "Test present after completion", message: nil, preferredStyle: .alert)
systemAlertController.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
self.present(systemAlertController, animated: true, completion: nil)
}

// Add the action.
Expand Down Expand Up @@ -172,7 +175,7 @@ class ViewController : UITableViewController, UITextFieldDelegate {
}

// Stop listening for text change notifications on the text field. This closure will be called in the two action handlers.
let removeTextFieldObserver: (Void) -> Void = {
let removeTextFieldObserver: () -> Void = {
NotificationCenter.default.removeObserver(self, name: NSNotification.Name.UITextFieldTextDidChange, object: alertController.textFields!.first)
}

Expand Down Expand Up @@ -391,11 +394,11 @@ class ViewController : UITableViewController, UITextFieldDelegate {

// MARK: UITextFieldTextDidChangeNotification

func handleTextFieldTextDidChangeNotification(_ notification: Notification) {
@objc func handleTextFieldTextDidChangeNotification(_ notification: Notification) {
let textField = notification.object as! UITextField

// Enforce a minimum length of >= 5 characters for secure text alerts.
secureTextAlertAction!.enabled = textField.text!.characters.count >= 5
secureTextAlertAction!.enabled = textField.text!.count >= 5
}

// MARK: UITextFieldDelegate Methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class DOAlertController_DEMOTests: XCTestCase {

func testPerformanceExample() {
// This is an example of a performance test case.
self.measureBlock() {
self.measure() {
// Put the code you want to measure the time of here.
}
}
Expand Down