├── .DS_Store ├── .gitignore ├── LICENSE ├── README.md ├── Tests ├── .DS_Store ├── UIAlertControllerBlocks.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── UIAlertControllerBlocks │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Base.lproj │ │ ├── LaunchScreen.xib │ │ └── Main.storyboard │ ├── Images.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Info.plist │ ├── SecondViewController.h │ ├── SecondViewController.m │ ├── ViewController.h │ ├── ViewController.m │ └── main.m ├── UIAlertControllerBlocksTVExample │ ├── Assets.xcassets │ │ ├── App Icon & Top Shelf Image.brandassets │ │ │ ├── App Icon - Large.imagestack │ │ │ │ ├── Back.imagestacklayer │ │ │ │ │ ├── Content.imageset │ │ │ │ │ │ └── Contents.json │ │ │ │ │ └── Contents.json │ │ │ │ ├── Contents.json │ │ │ │ ├── Front.imagestacklayer │ │ │ │ │ ├── Content.imageset │ │ │ │ │ │ └── Contents.json │ │ │ │ │ └── Contents.json │ │ │ │ └── Middle.imagestacklayer │ │ │ │ │ ├── Content.imageset │ │ │ │ │ └── Contents.json │ │ │ │ │ └── Contents.json │ │ │ ├── App Icon - Small.imagestack │ │ │ │ ├── Back.imagestacklayer │ │ │ │ │ ├── Content.imageset │ │ │ │ │ │ └── Contents.json │ │ │ │ │ └── Contents.json │ │ │ │ ├── Contents.json │ │ │ │ ├── Front.imagestacklayer │ │ │ │ │ ├── Content.imageset │ │ │ │ │ │ └── Contents.json │ │ │ │ │ └── Contents.json │ │ │ │ └── Middle.imagestacklayer │ │ │ │ │ ├── Content.imageset │ │ │ │ │ └── Contents.json │ │ │ │ │ └── Contents.json │ │ │ ├── Contents.json │ │ │ └── Top Shelf Image.imageset │ │ │ │ └── Contents.json │ │ ├── Contents.json │ │ └── LaunchImage.launchimage │ │ │ └── Contents.json │ ├── Base.lproj │ │ └── Main.storyboard │ ├── Info.plist │ └── main.m └── UIAlertControllerBlocksTests │ ├── Info.plist │ └── UIAlertControllerBlocksTests.m ├── UIAlertController+Blocks.h ├── UIAlertController+Blocks.m └── UIAlertController+Blocks.podspec /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanmaxwell/UIAlertController-Blocks/15c3479e31cdf582f45acb222912e954d812e896/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | # Pods/ 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Ryan Maxwell 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | UIAlertController+Blocks 2 | ======================== 3 | 4 | Convenience methods for UIAlertController. The API follows the same pattern as [UIAlertView+Blocks](https://github.com/ryanmaxwell/UIAlertView-Blocks) and [UIActionSheet+Blocks](https://github.com/ryanmaxwell/UIActionSheet-Blocks) 5 | 6 | Create and show an alert controller with a single call: 7 | 8 | ### Objective-C 9 | 10 | ```objc 11 | [UIAlertController showAlertInViewController:self 12 | withTitle:@"Test Alert" 13 | message:@"Test Message" 14 | cancelButtonTitle:@"Cancel" 15 | destructiveButtonTitle:@"Delete" 16 | otherButtonTitles:@[@"First Other", @"Second Other"] 17 | tapBlock:^(UIAlertController *controller, UIAlertAction *action, NSInteger buttonIndex){ 18 | 19 | if (buttonIndex == controller.cancelButtonIndex) { 20 | NSLog(@"Cancel Tapped"); 21 | } else if (buttonIndex == controller.destructiveButtonIndex) { 22 | NSLog(@"Delete Tapped"); 23 | } else if (buttonIndex >= controller.firstOtherButtonIndex) { 24 | NSLog(@"Other Button Index %ld", (long)buttonIndex - controller.firstOtherButtonIndex); 25 | } 26 | }]; 27 | ``` 28 | 29 | ### Swift 30 | 31 | ```swift 32 | UIAlertController.showAlert( 33 | in: self, 34 | withTitle: "Test Alert", 35 | message: "Test Message", 36 | cancelButtonTitle: "Cancel", 37 | destructiveButtonTitle: "Delete", 38 | otherButtonTitles: ["First Other", "Second Other"], 39 | tap: {(controller, action, buttonIndex) in 40 | if (buttonIndex == controller.cancelButtonIndex) { 41 | print("Cancel Tapped") 42 | } else if (buttonIndex == controller.destructiveButtonIndex) { 43 | print("Delete Tapped") 44 | } else if (buttonIndex >= controller.firstOtherButtonIndex) { 45 | print("Other Button Index \(buttonIndex - controller.firstOtherButtonIndex)") 46 | } 47 | } 48 | ) 49 | ``` 50 | 51 | Explicitly create alerts or action sheets with 52 | 53 | ```objc 54 | + (instancetype)showAlertInViewController:(UIViewController *)viewController 55 | withTitle:(NSString *)title 56 | message:(NSString *)message 57 | cancelButtonTitle:(NSString *)cancelButtonTitle 58 | destructiveButtonTitle:(NSString *)destructiveButtonTitle 59 | otherButtonTitles:(NSArray *)otherButtonTitles 60 | tapBlock:(UIAlertControllerCompletionBlock)tapBlock; 61 | ``` 62 | 63 | and 64 | 65 | ```objc 66 | + (instancetype)showActionSheetInViewController:(UIViewController *)viewController 67 | withTitle:(NSString *)title 68 | message:(NSString *)message 69 | cancelButtonTitle:(NSString *)cancelButtonTitle 70 | destructiveButtonTitle:(NSString *)destructiveButtonTitle 71 | otherButtonTitles:(NSArray *)otherButtonTitles 72 | popoverPresentationControllerBlock:(void(^)(UIPopoverPresentationController *popover))popoverPresentationControllerBlock 73 | tapBlock:(UIAlertControllerCompletionBlock)tapBlock; 74 | ``` 75 | 76 | ## Requirements 77 | 78 | Since version 0.9 the headers use the new Objective-C [nullability annotations](https://developer.apple.com/swift/blog/?id=25) for nicer interoperability with Swift, so you will need Xcode 6.3 or later to compile it. 79 | 80 | ## Usage 81 | 82 | Add `UIAlertController+Blocks.h/m` into your project, or `pod 'UIAlertController+Blocks'` using CocoaPods. 83 | In your code, either `#import ` (Objective-C header), `@import UIAlertController_Blocks;` (Objective-C module), or `import UIAlertController_Blocks` (Swift). 84 | 85 | ## Supporting < iOS 8 86 | 87 | You can add this pod to your project, along with 'UIAlertView+Blocks' or 'UIActionSheet+Blocks', and as long as you build with the iOS 8 SDK or greater, instantiate the appropriate class at runtime. e.g. 88 | 89 | ```objc 90 | 91 | void(^deleteSalesOrderBlock)(void) = ^{ 92 | /* Delete the sales order here */ 93 | }; 94 | 95 | if ([UIAlertController class]) { 96 | 97 | /* UIAlertController is preferable on >= iOS 8, as the destructive button will be in red */ 98 | 99 | [UIAlertController showAlertInViewController:self 100 | withTitle:NSLocalizedString(@"AlertTitleDeleteSalesOrder", nil) 101 | message:NSLocalizedString(@"AlertMessageDeleteSalesOrder", nil) 102 | cancelButtonTitle:NSLocalizedString(@"AlertButtonTitleCancel", nil) 103 | destructiveButtonTitle:NSLocalizedString(@"AlertButtonTitleDelete", nil) 104 | otherButtonTitles:nil 105 | tapBlock:^(UIAlertController *controller, UIAlertAction *action, NSInteger buttonIndex){ 106 | if (buttonIndex == controller.destructiveButtonIndex) { 107 | deleteSalesOrderBlock(); 108 | } 109 | }]; 110 | 111 | 112 | } else { 113 | [UIAlertView showWithTitle:NSLocalizedString(@"AlertTitleDeleteSalesOrder", nil) 114 | message:NSLocalizedString(@"AlertMessageDeleteSalesOrder", nil) 115 | cancelButtonTitle:NSLocalizedString(@"AlertButtonTitleCancel", nil) 116 | otherButtonTitles:@[NSLocalizedString(@"AlertButtonTitleDelete", nil)] 117 | tapBlock:^(UIAlertView *alertView, NSInteger buttonIndex){ 118 | if (buttonIndex == alertView.firstOtherButtonIndex) { 119 | deleteSalesOrderBlock(); 120 | } 121 | }]; 122 | } 123 | 124 | ``` 125 | 126 | I have also created the wrapper class [RMUniversalAlert](https://github.com/ryanmaxwell/RMUniversalAlert) which can do the above automatically for you. 127 | -------------------------------------------------------------------------------- /Tests/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanmaxwell/UIAlertController-Blocks/15c3479e31cdf582f45acb222912e954d812e896/Tests/.DS_Store -------------------------------------------------------------------------------- /Tests/UIAlertControllerBlocks.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 944A455719C14996001A402B /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 944A455619C14996001A402B /* main.m */; }; 11 | 944A455A19C14996001A402B /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 944A455919C14996001A402B /* AppDelegate.m */; }; 12 | 944A455D19C14996001A402B /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 944A455C19C14996001A402B /* ViewController.m */; }; 13 | 944A456019C14996001A402B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 944A455E19C14996001A402B /* Main.storyboard */; }; 14 | 944A456219C14996001A402B /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 944A456119C14996001A402B /* Images.xcassets */; }; 15 | 944A456519C14996001A402B /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 944A456319C14996001A402B /* LaunchScreen.xib */; }; 16 | 944A457119C14996001A402B /* UIAlertControllerBlocksTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 944A457019C14996001A402B /* UIAlertControllerBlocksTests.m */; }; 17 | 945D806D1DB8CE9100283692 /* SecondViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 945D806C1DB8CE9100283692 /* SecondViewController.m */; }; 18 | 945D806E1DB8D26A00283692 /* SecondViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 945D806C1DB8CE9100283692 /* SecondViewController.m */; }; 19 | 947490511D5BD89B00D606FB /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 947490501D5BD89B00D606FB /* main.m */; }; 20 | 9474905A1D5BD89B00D606FB /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 947490581D5BD89B00D606FB /* Main.storyboard */; }; 21 | 9474905C1D5BD89B00D606FB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9474905B1D5BD89B00D606FB /* Assets.xcassets */; }; 22 | 947490611D5BD8BC00D606FB /* UIAlertController+Blocks.m in Sources */ = {isa = PBXBuildFile; fileRef = 94B2A8821A18CB60002602A4 /* UIAlertController+Blocks.m */; }; 23 | 947490621D5BDAA500D606FB /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 944A455919C14996001A402B /* AppDelegate.m */; }; 24 | 947490631D5BDAA700D606FB /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 944A455C19C14996001A402B /* ViewController.m */; }; 25 | 94B2A8831A18CB60002602A4 /* UIAlertController+Blocks.m in Sources */ = {isa = PBXBuildFile; fileRef = 94B2A8821A18CB60002602A4 /* UIAlertController+Blocks.m */; }; 26 | 94B2A8841A18CB60002602A4 /* UIAlertController+Blocks.m in Sources */ = {isa = PBXBuildFile; fileRef = 94B2A8821A18CB60002602A4 /* UIAlertController+Blocks.m */; }; 27 | /* End PBXBuildFile section */ 28 | 29 | /* Begin PBXContainerItemProxy section */ 30 | 944A456B19C14996001A402B /* PBXContainerItemProxy */ = { 31 | isa = PBXContainerItemProxy; 32 | containerPortal = 944A454919C14996001A402B /* Project object */; 33 | proxyType = 1; 34 | remoteGlobalIDString = 944A455019C14996001A402B; 35 | remoteInfo = UIAlertControllerBlocks; 36 | }; 37 | /* End PBXContainerItemProxy section */ 38 | 39 | /* Begin PBXFileReference section */ 40 | 944A455119C14996001A402B /* UIAlertControllerBlocksExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = UIAlertControllerBlocksExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 41 | 944A455519C14996001A402B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 42 | 944A455619C14996001A402B /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 43 | 944A455819C14996001A402B /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 44 | 944A455919C14996001A402B /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 45 | 944A455B19C14996001A402B /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 46 | 944A455C19C14996001A402B /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 47 | 944A455F19C14996001A402B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 48 | 944A456119C14996001A402B /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 49 | 944A456419C14996001A402B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 50 | 944A456A19C14996001A402B /* UIAlertControllerBlocksTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = UIAlertControllerBlocksTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 51 | 944A456F19C14996001A402B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 52 | 944A457019C14996001A402B /* UIAlertControllerBlocksTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = UIAlertControllerBlocksTests.m; sourceTree = ""; }; 53 | 945D806B1DB8CE9100283692 /* SecondViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SecondViewController.h; sourceTree = ""; }; 54 | 945D806C1DB8CE9100283692 /* SecondViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SecondViewController.m; sourceTree = ""; }; 55 | 9474904D1D5BD89B00D606FB /* UIAlertControllerBlocksTVExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = UIAlertControllerBlocksTVExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 56 | 947490501D5BD89B00D606FB /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 57 | 947490591D5BD89B00D606FB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 58 | 9474905B1D5BD89B00D606FB /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 59 | 9474905D1D5BD89B00D606FB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 60 | 94B2A8811A18CB60002602A4 /* UIAlertController+Blocks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIAlertController+Blocks.h"; path = "../UIAlertController+Blocks.h"; sourceTree = ""; }; 61 | 94B2A8821A18CB60002602A4 /* UIAlertController+Blocks.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIAlertController+Blocks.m"; path = "../UIAlertController+Blocks.m"; sourceTree = ""; }; 62 | /* End PBXFileReference section */ 63 | 64 | /* Begin PBXFrameworksBuildPhase section */ 65 | 944A454E19C14996001A402B /* Frameworks */ = { 66 | isa = PBXFrameworksBuildPhase; 67 | buildActionMask = 2147483647; 68 | files = ( 69 | ); 70 | runOnlyForDeploymentPostprocessing = 0; 71 | }; 72 | 944A456719C14996001A402B /* Frameworks */ = { 73 | isa = PBXFrameworksBuildPhase; 74 | buildActionMask = 2147483647; 75 | files = ( 76 | ); 77 | runOnlyForDeploymentPostprocessing = 0; 78 | }; 79 | 9474904A1D5BD89B00D606FB /* Frameworks */ = { 80 | isa = PBXFrameworksBuildPhase; 81 | buildActionMask = 2147483647; 82 | files = ( 83 | ); 84 | runOnlyForDeploymentPostprocessing = 0; 85 | }; 86 | /* End PBXFrameworksBuildPhase section */ 87 | 88 | /* Begin PBXGroup section */ 89 | 944A454819C14996001A402B = { 90 | isa = PBXGroup; 91 | children = ( 92 | 94B2A8811A18CB60002602A4 /* UIAlertController+Blocks.h */, 93 | 94B2A8821A18CB60002602A4 /* UIAlertController+Blocks.m */, 94 | 944A455319C14996001A402B /* UIAlertControllerBlocks */, 95 | 944A456D19C14996001A402B /* UIAlertControllerBlocksTests */, 96 | 9474904E1D5BD89B00D606FB /* UIAlertControllerBlocksTVExample */, 97 | 944A455219C14996001A402B /* Products */, 98 | ); 99 | sourceTree = ""; 100 | }; 101 | 944A455219C14996001A402B /* Products */ = { 102 | isa = PBXGroup; 103 | children = ( 104 | 944A455119C14996001A402B /* UIAlertControllerBlocksExample.app */, 105 | 944A456A19C14996001A402B /* UIAlertControllerBlocksTests.xctest */, 106 | 9474904D1D5BD89B00D606FB /* UIAlertControllerBlocksTVExample.app */, 107 | ); 108 | name = Products; 109 | sourceTree = ""; 110 | }; 111 | 944A455319C14996001A402B /* UIAlertControllerBlocks */ = { 112 | isa = PBXGroup; 113 | children = ( 114 | 944A455819C14996001A402B /* AppDelegate.h */, 115 | 944A455919C14996001A402B /* AppDelegate.m */, 116 | 944A455B19C14996001A402B /* ViewController.h */, 117 | 944A455C19C14996001A402B /* ViewController.m */, 118 | 944A455E19C14996001A402B /* Main.storyboard */, 119 | 944A456119C14996001A402B /* Images.xcassets */, 120 | 944A456319C14996001A402B /* LaunchScreen.xib */, 121 | 944A455419C14996001A402B /* Supporting Files */, 122 | 945D806B1DB8CE9100283692 /* SecondViewController.h */, 123 | 945D806C1DB8CE9100283692 /* SecondViewController.m */, 124 | ); 125 | path = UIAlertControllerBlocks; 126 | sourceTree = ""; 127 | }; 128 | 944A455419C14996001A402B /* Supporting Files */ = { 129 | isa = PBXGroup; 130 | children = ( 131 | 944A455519C14996001A402B /* Info.plist */, 132 | 944A455619C14996001A402B /* main.m */, 133 | ); 134 | name = "Supporting Files"; 135 | sourceTree = ""; 136 | }; 137 | 944A456D19C14996001A402B /* UIAlertControllerBlocksTests */ = { 138 | isa = PBXGroup; 139 | children = ( 140 | 944A457019C14996001A402B /* UIAlertControllerBlocksTests.m */, 141 | 944A456E19C14996001A402B /* Supporting Files */, 142 | ); 143 | path = UIAlertControllerBlocksTests; 144 | sourceTree = ""; 145 | }; 146 | 944A456E19C14996001A402B /* Supporting Files */ = { 147 | isa = PBXGroup; 148 | children = ( 149 | 944A456F19C14996001A402B /* Info.plist */, 150 | ); 151 | name = "Supporting Files"; 152 | sourceTree = ""; 153 | }; 154 | 9474904E1D5BD89B00D606FB /* UIAlertControllerBlocksTVExample */ = { 155 | isa = PBXGroup; 156 | children = ( 157 | 947490581D5BD89B00D606FB /* Main.storyboard */, 158 | 9474905B1D5BD89B00D606FB /* Assets.xcassets */, 159 | 9474905D1D5BD89B00D606FB /* Info.plist */, 160 | 9474904F1D5BD89B00D606FB /* Supporting Files */, 161 | ); 162 | path = UIAlertControllerBlocksTVExample; 163 | sourceTree = ""; 164 | }; 165 | 9474904F1D5BD89B00D606FB /* Supporting Files */ = { 166 | isa = PBXGroup; 167 | children = ( 168 | 947490501D5BD89B00D606FB /* main.m */, 169 | ); 170 | name = "Supporting Files"; 171 | sourceTree = ""; 172 | }; 173 | /* End PBXGroup section */ 174 | 175 | /* Begin PBXNativeTarget section */ 176 | 944A455019C14996001A402B /* UIAlertControllerBlocksExample */ = { 177 | isa = PBXNativeTarget; 178 | buildConfigurationList = 944A457419C14996001A402B /* Build configuration list for PBXNativeTarget "UIAlertControllerBlocksExample" */; 179 | buildPhases = ( 180 | 944A454D19C14996001A402B /* Sources */, 181 | 944A454E19C14996001A402B /* Frameworks */, 182 | 944A454F19C14996001A402B /* Resources */, 183 | ); 184 | buildRules = ( 185 | ); 186 | dependencies = ( 187 | ); 188 | name = UIAlertControllerBlocksExample; 189 | productName = UIAlertControllerBlocks; 190 | productReference = 944A455119C14996001A402B /* UIAlertControllerBlocksExample.app */; 191 | productType = "com.apple.product-type.application"; 192 | }; 193 | 944A456919C14996001A402B /* UIAlertControllerBlocksTests */ = { 194 | isa = PBXNativeTarget; 195 | buildConfigurationList = 944A457719C14996001A402B /* Build configuration list for PBXNativeTarget "UIAlertControllerBlocksTests" */; 196 | buildPhases = ( 197 | 944A456619C14996001A402B /* Sources */, 198 | 944A456719C14996001A402B /* Frameworks */, 199 | 944A456819C14996001A402B /* Resources */, 200 | ); 201 | buildRules = ( 202 | ); 203 | dependencies = ( 204 | 944A456C19C14996001A402B /* PBXTargetDependency */, 205 | ); 206 | name = UIAlertControllerBlocksTests; 207 | productName = UIAlertControllerBlocksTests; 208 | productReference = 944A456A19C14996001A402B /* UIAlertControllerBlocksTests.xctest */; 209 | productType = "com.apple.product-type.bundle.unit-test"; 210 | }; 211 | 9474904C1D5BD89B00D606FB /* UIAlertControllerBlocksTVExample */ = { 212 | isa = PBXNativeTarget; 213 | buildConfigurationList = 9474905E1D5BD89B00D606FB /* Build configuration list for PBXNativeTarget "UIAlertControllerBlocksTVExample" */; 214 | buildPhases = ( 215 | 947490491D5BD89B00D606FB /* Sources */, 216 | 9474904A1D5BD89B00D606FB /* Frameworks */, 217 | 9474904B1D5BD89B00D606FB /* Resources */, 218 | ); 219 | buildRules = ( 220 | ); 221 | dependencies = ( 222 | ); 223 | name = UIAlertControllerBlocksTVExample; 224 | productName = UIAlertControllerBlocksTVExample; 225 | productReference = 9474904D1D5BD89B00D606FB /* UIAlertControllerBlocksTVExample.app */; 226 | productType = "com.apple.product-type.application"; 227 | }; 228 | /* End PBXNativeTarget section */ 229 | 230 | /* Begin PBXProject section */ 231 | 944A454919C14996001A402B /* Project object */ = { 232 | isa = PBXProject; 233 | attributes = { 234 | LastUpgradeCheck = 0600; 235 | ORGANIZATIONNAME = "Ryan Maxwell"; 236 | TargetAttributes = { 237 | 944A455019C14996001A402B = { 238 | CreatedOnToolsVersion = 6.0; 239 | }; 240 | 944A456919C14996001A402B = { 241 | CreatedOnToolsVersion = 6.0; 242 | TestTargetID = 944A455019C14996001A402B; 243 | }; 244 | 9474904C1D5BD89B00D606FB = { 245 | CreatedOnToolsVersion = 7.3.1; 246 | }; 247 | }; 248 | }; 249 | buildConfigurationList = 944A454C19C14996001A402B /* Build configuration list for PBXProject "UIAlertControllerBlocks" */; 250 | compatibilityVersion = "Xcode 3.2"; 251 | developmentRegion = English; 252 | hasScannedForEncodings = 0; 253 | knownRegions = ( 254 | en, 255 | Base, 256 | ); 257 | mainGroup = 944A454819C14996001A402B; 258 | productRefGroup = 944A455219C14996001A402B /* Products */; 259 | projectDirPath = ""; 260 | projectRoot = ""; 261 | targets = ( 262 | 944A455019C14996001A402B /* UIAlertControllerBlocksExample */, 263 | 944A456919C14996001A402B /* UIAlertControllerBlocksTests */, 264 | 9474904C1D5BD89B00D606FB /* UIAlertControllerBlocksTVExample */, 265 | ); 266 | }; 267 | /* End PBXProject section */ 268 | 269 | /* Begin PBXResourcesBuildPhase section */ 270 | 944A454F19C14996001A402B /* Resources */ = { 271 | isa = PBXResourcesBuildPhase; 272 | buildActionMask = 2147483647; 273 | files = ( 274 | 944A456019C14996001A402B /* Main.storyboard in Resources */, 275 | 944A456519C14996001A402B /* LaunchScreen.xib in Resources */, 276 | 944A456219C14996001A402B /* Images.xcassets in Resources */, 277 | ); 278 | runOnlyForDeploymentPostprocessing = 0; 279 | }; 280 | 944A456819C14996001A402B /* Resources */ = { 281 | isa = PBXResourcesBuildPhase; 282 | buildActionMask = 2147483647; 283 | files = ( 284 | ); 285 | runOnlyForDeploymentPostprocessing = 0; 286 | }; 287 | 9474904B1D5BD89B00D606FB /* Resources */ = { 288 | isa = PBXResourcesBuildPhase; 289 | buildActionMask = 2147483647; 290 | files = ( 291 | 9474905C1D5BD89B00D606FB /* Assets.xcassets in Resources */, 292 | 9474905A1D5BD89B00D606FB /* Main.storyboard in Resources */, 293 | ); 294 | runOnlyForDeploymentPostprocessing = 0; 295 | }; 296 | /* End PBXResourcesBuildPhase section */ 297 | 298 | /* Begin PBXSourcesBuildPhase section */ 299 | 944A454D19C14996001A402B /* Sources */ = { 300 | isa = PBXSourcesBuildPhase; 301 | buildActionMask = 2147483647; 302 | files = ( 303 | 945D806D1DB8CE9100283692 /* SecondViewController.m in Sources */, 304 | 94B2A8831A18CB60002602A4 /* UIAlertController+Blocks.m in Sources */, 305 | 944A455D19C14996001A402B /* ViewController.m in Sources */, 306 | 944A455A19C14996001A402B /* AppDelegate.m in Sources */, 307 | 944A455719C14996001A402B /* main.m in Sources */, 308 | ); 309 | runOnlyForDeploymentPostprocessing = 0; 310 | }; 311 | 944A456619C14996001A402B /* Sources */ = { 312 | isa = PBXSourcesBuildPhase; 313 | buildActionMask = 2147483647; 314 | files = ( 315 | 94B2A8841A18CB60002602A4 /* UIAlertController+Blocks.m in Sources */, 316 | 944A457119C14996001A402B /* UIAlertControllerBlocksTests.m in Sources */, 317 | ); 318 | runOnlyForDeploymentPostprocessing = 0; 319 | }; 320 | 947490491D5BD89B00D606FB /* Sources */ = { 321 | isa = PBXSourcesBuildPhase; 322 | buildActionMask = 2147483647; 323 | files = ( 324 | 945D806E1DB8D26A00283692 /* SecondViewController.m in Sources */, 325 | 947490611D5BD8BC00D606FB /* UIAlertController+Blocks.m in Sources */, 326 | 947490511D5BD89B00D606FB /* main.m in Sources */, 327 | 947490631D5BDAA700D606FB /* ViewController.m in Sources */, 328 | 947490621D5BDAA500D606FB /* AppDelegate.m in Sources */, 329 | ); 330 | runOnlyForDeploymentPostprocessing = 0; 331 | }; 332 | /* End PBXSourcesBuildPhase section */ 333 | 334 | /* Begin PBXTargetDependency section */ 335 | 944A456C19C14996001A402B /* PBXTargetDependency */ = { 336 | isa = PBXTargetDependency; 337 | target = 944A455019C14996001A402B /* UIAlertControllerBlocksExample */; 338 | targetProxy = 944A456B19C14996001A402B /* PBXContainerItemProxy */; 339 | }; 340 | /* End PBXTargetDependency section */ 341 | 342 | /* Begin PBXVariantGroup section */ 343 | 944A455E19C14996001A402B /* Main.storyboard */ = { 344 | isa = PBXVariantGroup; 345 | children = ( 346 | 944A455F19C14996001A402B /* Base */, 347 | ); 348 | name = Main.storyboard; 349 | sourceTree = ""; 350 | }; 351 | 944A456319C14996001A402B /* LaunchScreen.xib */ = { 352 | isa = PBXVariantGroup; 353 | children = ( 354 | 944A456419C14996001A402B /* Base */, 355 | ); 356 | name = LaunchScreen.xib; 357 | sourceTree = ""; 358 | }; 359 | 947490581D5BD89B00D606FB /* Main.storyboard */ = { 360 | isa = PBXVariantGroup; 361 | children = ( 362 | 947490591D5BD89B00D606FB /* Base */, 363 | ); 364 | name = Main.storyboard; 365 | sourceTree = ""; 366 | }; 367 | /* End PBXVariantGroup section */ 368 | 369 | /* Begin XCBuildConfiguration section */ 370 | 944A457219C14996001A402B /* Debug */ = { 371 | isa = XCBuildConfiguration; 372 | buildSettings = { 373 | ALWAYS_SEARCH_USER_PATHS = NO; 374 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 375 | CLANG_CXX_LIBRARY = "libc++"; 376 | CLANG_ENABLE_MODULES = YES; 377 | CLANG_ENABLE_OBJC_ARC = YES; 378 | CLANG_WARN_BOOL_CONVERSION = YES; 379 | CLANG_WARN_CONSTANT_CONVERSION = YES; 380 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 381 | CLANG_WARN_EMPTY_BODY = YES; 382 | CLANG_WARN_ENUM_CONVERSION = YES; 383 | CLANG_WARN_INT_CONVERSION = YES; 384 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 385 | CLANG_WARN_UNREACHABLE_CODE = YES; 386 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 387 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 388 | COPY_PHASE_STRIP = NO; 389 | ENABLE_STRICT_OBJC_MSGSEND = YES; 390 | GCC_C_LANGUAGE_STANDARD = gnu99; 391 | GCC_DYNAMIC_NO_PIC = NO; 392 | GCC_OPTIMIZATION_LEVEL = 0; 393 | GCC_PREPROCESSOR_DEFINITIONS = ( 394 | "DEBUG=1", 395 | "$(inherited)", 396 | ); 397 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 398 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 399 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 400 | GCC_WARN_UNDECLARED_SELECTOR = YES; 401 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 402 | GCC_WARN_UNUSED_FUNCTION = YES; 403 | GCC_WARN_UNUSED_VARIABLE = YES; 404 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 405 | MTL_ENABLE_DEBUG_INFO = YES; 406 | ONLY_ACTIVE_ARCH = YES; 407 | SDKROOT = iphoneos; 408 | TARGETED_DEVICE_FAMILY = "1,2"; 409 | }; 410 | name = Debug; 411 | }; 412 | 944A457319C14996001A402B /* Release */ = { 413 | isa = XCBuildConfiguration; 414 | buildSettings = { 415 | ALWAYS_SEARCH_USER_PATHS = NO; 416 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 417 | CLANG_CXX_LIBRARY = "libc++"; 418 | CLANG_ENABLE_MODULES = YES; 419 | CLANG_ENABLE_OBJC_ARC = YES; 420 | CLANG_WARN_BOOL_CONVERSION = YES; 421 | CLANG_WARN_CONSTANT_CONVERSION = YES; 422 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 423 | CLANG_WARN_EMPTY_BODY = YES; 424 | CLANG_WARN_ENUM_CONVERSION = YES; 425 | CLANG_WARN_INT_CONVERSION = YES; 426 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 427 | CLANG_WARN_UNREACHABLE_CODE = YES; 428 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 429 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 430 | COPY_PHASE_STRIP = YES; 431 | ENABLE_NS_ASSERTIONS = NO; 432 | ENABLE_STRICT_OBJC_MSGSEND = YES; 433 | GCC_C_LANGUAGE_STANDARD = gnu99; 434 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 435 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 436 | GCC_WARN_UNDECLARED_SELECTOR = YES; 437 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 438 | GCC_WARN_UNUSED_FUNCTION = YES; 439 | GCC_WARN_UNUSED_VARIABLE = YES; 440 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 441 | MTL_ENABLE_DEBUG_INFO = NO; 442 | SDKROOT = iphoneos; 443 | TARGETED_DEVICE_FAMILY = "1,2"; 444 | VALIDATE_PRODUCT = YES; 445 | }; 446 | name = Release; 447 | }; 448 | 944A457519C14996001A402B /* Debug */ = { 449 | isa = XCBuildConfiguration; 450 | buildSettings = { 451 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 452 | INFOPLIST_FILE = UIAlertControllerBlocks/Info.plist; 453 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 454 | PRODUCT_NAME = "$(TARGET_NAME)"; 455 | }; 456 | name = Debug; 457 | }; 458 | 944A457619C14996001A402B /* Release */ = { 459 | isa = XCBuildConfiguration; 460 | buildSettings = { 461 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 462 | INFOPLIST_FILE = UIAlertControllerBlocks/Info.plist; 463 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 464 | PRODUCT_NAME = "$(TARGET_NAME)"; 465 | }; 466 | name = Release; 467 | }; 468 | 944A457819C14996001A402B /* Debug */ = { 469 | isa = XCBuildConfiguration; 470 | buildSettings = { 471 | BUNDLE_LOADER = "$(TEST_HOST)"; 472 | FRAMEWORK_SEARCH_PATHS = ( 473 | "$(SDKROOT)/Developer/Library/Frameworks", 474 | "$(inherited)", 475 | ); 476 | GCC_PREPROCESSOR_DEFINITIONS = ( 477 | "DEBUG=1", 478 | "$(inherited)", 479 | ); 480 | INFOPLIST_FILE = UIAlertControllerBlocksTests/Info.plist; 481 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 482 | PRODUCT_NAME = "$(TARGET_NAME)"; 483 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/UIAlertControllerBlocks.app/UIAlertControllerBlocks"; 484 | }; 485 | name = Debug; 486 | }; 487 | 944A457919C14996001A402B /* Release */ = { 488 | isa = XCBuildConfiguration; 489 | buildSettings = { 490 | BUNDLE_LOADER = "$(TEST_HOST)"; 491 | FRAMEWORK_SEARCH_PATHS = ( 492 | "$(SDKROOT)/Developer/Library/Frameworks", 493 | "$(inherited)", 494 | ); 495 | INFOPLIST_FILE = UIAlertControllerBlocksTests/Info.plist; 496 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 497 | PRODUCT_NAME = "$(TARGET_NAME)"; 498 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/UIAlertControllerBlocks.app/UIAlertControllerBlocks"; 499 | }; 500 | name = Release; 501 | }; 502 | 9474905F1D5BD89B00D606FB /* Debug */ = { 503 | isa = XCBuildConfiguration; 504 | buildSettings = { 505 | ASSETCATALOG_COMPILER_APPICON_NAME = "App Icon & Top Shelf Image"; 506 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 507 | CLANG_ANALYZER_NONNULL = YES; 508 | DEBUG_INFORMATION_FORMAT = dwarf; 509 | ENABLE_TESTABILITY = YES; 510 | GCC_NO_COMMON_BLOCKS = YES; 511 | INFOPLIST_FILE = UIAlertControllerBlocksTVExample/Info.plist; 512 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 513 | PRODUCT_BUNDLE_IDENTIFIER = nz.co.xwell.UIAlertControllerBlocksTVExample; 514 | PRODUCT_NAME = "$(TARGET_NAME)"; 515 | SDKROOT = appletvos; 516 | TARGETED_DEVICE_FAMILY = 3; 517 | TVOS_DEPLOYMENT_TARGET = 9.2; 518 | }; 519 | name = Debug; 520 | }; 521 | 947490601D5BD89B00D606FB /* Release */ = { 522 | isa = XCBuildConfiguration; 523 | buildSettings = { 524 | ASSETCATALOG_COMPILER_APPICON_NAME = "App Icon & Top Shelf Image"; 525 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 526 | CLANG_ANALYZER_NONNULL = YES; 527 | COPY_PHASE_STRIP = NO; 528 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 529 | GCC_NO_COMMON_BLOCKS = YES; 530 | INFOPLIST_FILE = UIAlertControllerBlocksTVExample/Info.plist; 531 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 532 | PRODUCT_BUNDLE_IDENTIFIER = nz.co.xwell.UIAlertControllerBlocksTVExample; 533 | PRODUCT_NAME = "$(TARGET_NAME)"; 534 | SDKROOT = appletvos; 535 | TARGETED_DEVICE_FAMILY = 3; 536 | TVOS_DEPLOYMENT_TARGET = 9.2; 537 | }; 538 | name = Release; 539 | }; 540 | /* End XCBuildConfiguration section */ 541 | 542 | /* Begin XCConfigurationList section */ 543 | 944A454C19C14996001A402B /* Build configuration list for PBXProject "UIAlertControllerBlocks" */ = { 544 | isa = XCConfigurationList; 545 | buildConfigurations = ( 546 | 944A457219C14996001A402B /* Debug */, 547 | 944A457319C14996001A402B /* Release */, 548 | ); 549 | defaultConfigurationIsVisible = 0; 550 | defaultConfigurationName = Release; 551 | }; 552 | 944A457419C14996001A402B /* Build configuration list for PBXNativeTarget "UIAlertControllerBlocksExample" */ = { 553 | isa = XCConfigurationList; 554 | buildConfigurations = ( 555 | 944A457519C14996001A402B /* Debug */, 556 | 944A457619C14996001A402B /* Release */, 557 | ); 558 | defaultConfigurationIsVisible = 0; 559 | defaultConfigurationName = Release; 560 | }; 561 | 944A457719C14996001A402B /* Build configuration list for PBXNativeTarget "UIAlertControllerBlocksTests" */ = { 562 | isa = XCConfigurationList; 563 | buildConfigurations = ( 564 | 944A457819C14996001A402B /* Debug */, 565 | 944A457919C14996001A402B /* Release */, 566 | ); 567 | defaultConfigurationIsVisible = 0; 568 | defaultConfigurationName = Release; 569 | }; 570 | 9474905E1D5BD89B00D606FB /* Build configuration list for PBXNativeTarget "UIAlertControllerBlocksTVExample" */ = { 571 | isa = XCConfigurationList; 572 | buildConfigurations = ( 573 | 9474905F1D5BD89B00D606FB /* Debug */, 574 | 947490601D5BD89B00D606FB /* Release */, 575 | ); 576 | defaultConfigurationIsVisible = 0; 577 | defaultConfigurationName = Release; 578 | }; 579 | /* End XCConfigurationList section */ 580 | }; 581 | rootObject = 944A454919C14996001A402B /* Project object */; 582 | } 583 | -------------------------------------------------------------------------------- /Tests/UIAlertControllerBlocks.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Tests/UIAlertControllerBlocks/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // UIAlertControllerBlocks 4 | // 5 | // Created by Ryan Maxwell on 11/09/14. 6 | // Copyright (c) 2014 Ryan Maxwell. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /Tests/UIAlertControllerBlocks/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // UIAlertControllerBlocks 4 | // 5 | // Created by Ryan Maxwell on 11/09/14. 6 | // Copyright (c) 2014 Ryan Maxwell. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // 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. 25 | // 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. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // 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. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // 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. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // 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. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /Tests/UIAlertControllerBlocks/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 21 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /Tests/UIAlertControllerBlocks/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 29 | 37 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /Tests/UIAlertControllerBlocks/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /Tests/UIAlertControllerBlocks/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | nz.co.xwell.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /Tests/UIAlertControllerBlocks/SecondViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // SecondViewController.h 3 | // UIAlertControllerBlocks 4 | // 5 | // Created by Ryan Maxwell on 20/10/16. 6 | // Copyright © 2016 Ryan Maxwell. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SecondViewController : UIViewController 12 | 13 | @end 14 | 15 | @interface ThirdViewController : UIViewController 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Tests/UIAlertControllerBlocks/SecondViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // SecondViewController.m 3 | // UIAlertControllerBlocks 4 | // 5 | // Created by Ryan Maxwell on 20/10/16. 6 | // Copyright © 2016 Ryan Maxwell. All rights reserved. 7 | // 8 | 9 | #import "SecondViewController.h" 10 | 11 | @interface SecondViewController () 12 | 13 | @end 14 | 15 | @implementation SecondViewController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | 20 | self.view.backgroundColor = [UIColor blueColor]; 21 | } 22 | 23 | @end 24 | 25 | @implementation ThirdViewController 26 | 27 | - (void)viewDidLoad { 28 | [super viewDidLoad]; 29 | 30 | self.view.backgroundColor = [UIColor redColor]; 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Tests/UIAlertControllerBlocks/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // UIAlertControllerBlocks 4 | // 5 | // Created by Ryan Maxwell on 11/09/14. 6 | // Copyright (c) 2014 Ryan Maxwell. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /Tests/UIAlertControllerBlocks/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // UIAlertControllerBlocks 4 | // 5 | // Created by Ryan Maxwell on 11/09/14. 6 | // Copyright (c) 2014 Ryan Maxwell. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "UIAlertController+Blocks.h" 11 | #import "SecondViewController.h" 12 | 13 | @interface ViewController () 14 | 15 | @property (strong, nonatomic) UIAlertControllerCompletionBlock tapBlock; 16 | 17 | @end 18 | 19 | @implementation ViewController 20 | 21 | - (instancetype)initWithCoder:(NSCoder *)aDecoder 22 | { 23 | self = [super initWithCoder:aDecoder]; 24 | if (self) { 25 | self.tapBlock = ^(UIAlertController *controller, UIAlertAction *action, NSInteger buttonIndex){ 26 | if (buttonIndex == controller.destructiveButtonIndex) { 27 | NSLog(@"Delete"); 28 | } else if (buttonIndex == controller.cancelButtonIndex) { 29 | NSLog(@"Cancel"); 30 | } else if (buttonIndex >= controller.firstOtherButtonIndex) { 31 | NSLog(@"Other %ld", (long)buttonIndex - controller.firstOtherButtonIndex + 1); 32 | } 33 | }; 34 | } 35 | return self; 36 | } 37 | 38 | - (IBAction)showAlert:(id)sender 39 | { 40 | [UIAlertController showAlertInViewController:self 41 | withTitle:@"Test Alert" 42 | message:@"Test Message" 43 | cancelButtonTitle:@"Cancel" 44 | destructiveButtonTitle:@"Delete" 45 | otherButtonTitles:@[@"First Other", @"Second Other"] 46 | tapBlock:self.tapBlock]; 47 | } 48 | 49 | - (IBAction)showActionSheet:(UIButton *)sender 50 | { 51 | [UIAlertController showActionSheetInViewController:self 52 | withTitle:@"Test Action Sheet" 53 | message:@"Test Message" 54 | cancelButtonTitle:@"Cancel" 55 | destructiveButtonTitle:@"Delete" 56 | otherButtonTitles:@[@"First Other", @"Second Other"] 57 | #if TARGET_OS_IOS 58 | popoverPresentationControllerBlock:^(UIPopoverPresentationController *popover){ 59 | 60 | popover.sourceView = self.view; 61 | popover.sourceRect = sender.frame; 62 | } 63 | #endif 64 | tapBlock:self.tapBlock]; 65 | } 66 | 67 | - (IBAction)showAlertOverPresentedViewController 68 | { 69 | UIViewController *vc2 = [SecondViewController new]; 70 | [self presentViewController:vc2 animated:YES completion:^{ 71 | UIViewController *vc3 = [ThirdViewController new]; 72 | [vc2 presentViewController:vc3 animated:YES completion:^{ 73 | 74 | [UIAlertController showAlertInViewController:self 75 | withTitle:@"Test Alert" 76 | message:@"Test Message" 77 | cancelButtonTitle:@"OK" 78 | destructiveButtonTitle:nil 79 | otherButtonTitles:nil 80 | tapBlock:^(UIAlertController *controller, UIAlertAction *action, NSInteger buttonIndex){ 81 | [self dismissViewControllerAnimated:YES completion:^{ 82 | [self dismissViewControllerAnimated:YES completion:nil]; 83 | }]; 84 | }]; 85 | }]; 86 | 87 | }]; 88 | } 89 | 90 | 91 | @end 92 | -------------------------------------------------------------------------------- /Tests/UIAlertControllerBlocks/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // UIAlertControllerBlocks 4 | // 5 | // Created by Ryan Maxwell on 11/09/14. 6 | // Copyright (c) 2014 Ryan Maxwell. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Tests/UIAlertControllerBlocksTVExample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Back.imagestacklayer/Content.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "tv", 5 | "scale" : "1x" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /Tests/UIAlertControllerBlocksTVExample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Back.imagestacklayer/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Tests/UIAlertControllerBlocksTVExample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "layers" : [ 3 | { 4 | "filename" : "Front.imagestacklayer" 5 | }, 6 | { 7 | "filename" : "Middle.imagestacklayer" 8 | }, 9 | { 10 | "filename" : "Back.imagestacklayer" 11 | } 12 | ], 13 | "info" : { 14 | "version" : 1, 15 | "author" : "xcode" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Tests/UIAlertControllerBlocksTVExample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Front.imagestacklayer/Content.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "tv", 5 | "scale" : "1x" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /Tests/UIAlertControllerBlocksTVExample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Front.imagestacklayer/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Tests/UIAlertControllerBlocksTVExample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "tv", 5 | "scale" : "1x" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /Tests/UIAlertControllerBlocksTVExample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Middle.imagestacklayer/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Tests/UIAlertControllerBlocksTVExample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Back.imagestacklayer/Content.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "tv", 5 | "scale" : "1x" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /Tests/UIAlertControllerBlocksTVExample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Back.imagestacklayer/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Tests/UIAlertControllerBlocksTVExample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "layers" : [ 3 | { 4 | "filename" : "Front.imagestacklayer" 5 | }, 6 | { 7 | "filename" : "Middle.imagestacklayer" 8 | }, 9 | { 10 | "filename" : "Back.imagestacklayer" 11 | } 12 | ], 13 | "info" : { 14 | "version" : 1, 15 | "author" : "xcode" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Tests/UIAlertControllerBlocksTVExample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Front.imagestacklayer/Content.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "tv", 5 | "scale" : "1x" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /Tests/UIAlertControllerBlocksTVExample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Front.imagestacklayer/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Tests/UIAlertControllerBlocksTVExample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "tv", 5 | "scale" : "1x" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /Tests/UIAlertControllerBlocksTVExample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Middle.imagestacklayer/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Tests/UIAlertControllerBlocksTVExample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "assets" : [ 3 | { 4 | "size" : "1280x768", 5 | "idiom" : "tv", 6 | "filename" : "App Icon - Large.imagestack", 7 | "role" : "primary-app-icon" 8 | }, 9 | { 10 | "size" : "400x240", 11 | "idiom" : "tv", 12 | "filename" : "App Icon - Small.imagestack", 13 | "role" : "primary-app-icon" 14 | }, 15 | { 16 | "size" : "1920x720", 17 | "idiom" : "tv", 18 | "filename" : "Top Shelf Image.imageset", 19 | "role" : "top-shelf-image" 20 | } 21 | ], 22 | "info" : { 23 | "version" : 1, 24 | "author" : "xcode" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Tests/UIAlertControllerBlocksTVExample/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "tv", 5 | "scale" : "1x" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /Tests/UIAlertControllerBlocksTVExample/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Tests/UIAlertControllerBlocksTVExample/Assets.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "landscape", 5 | "idiom" : "tv", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "9.0", 8 | "scale" : "1x" 9 | } 10 | ], 11 | "info" : { 12 | "version" : 1, 13 | "author" : "xcode" 14 | } 15 | } -------------------------------------------------------------------------------- /Tests/UIAlertControllerBlocksTVExample/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 27 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /Tests/UIAlertControllerBlocksTVExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | arm64 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /Tests/UIAlertControllerBlocksTVExample/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // UIAlertControllerBlocksTVExample 4 | // 5 | // Created by Ryan Maxwell on 11/08/16. 6 | // Copyright © 2016 Ryan Maxwell. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Tests/UIAlertControllerBlocksTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | nz.co.xwell.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Tests/UIAlertControllerBlocksTests/UIAlertControllerBlocksTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIAlertControllerBlocksTests.m 3 | // UIAlertControllerBlocksTests 4 | // 5 | // Created by Ryan Maxwell on 11/09/14. 6 | // Copyright (c) 2014 Ryan Maxwell. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | #import "UIAlertController+Blocks.h" 13 | 14 | @interface UIAlertControllerBlocksTests : XCTestCase 15 | 16 | @end 17 | 18 | @implementation UIAlertControllerBlocksTests 19 | 20 | - (void)setUp { 21 | [super setUp]; 22 | // Put setup code here. This method is called before the invocation of each test method in the class. 23 | } 24 | 25 | - (void)tearDown { 26 | // Put teardown code here. This method is called after the invocation of each test method in the class. 27 | [super tearDown]; 28 | } 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /UIAlertController+Blocks.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIAlertController+Blocks.h 3 | // UIAlertControllerBlocks 4 | // 5 | // Created by Ryan Maxwell on 11/09/14. 6 | // 7 | // The MIT License (MIT) 8 | // 9 | // Copyright (c) 2014 Ryan Maxwell 10 | // 11 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 12 | // this software and associated documentation files (the "Software"), to deal in 13 | // the Software without restriction, including without limitation the rights to 14 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 15 | // the Software, and to permit persons to whom the Software is furnished to do so, 16 | // subject to the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be included in all 19 | // copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 23 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 24 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 25 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | #import 30 | 31 | #if TARGET_OS_IOS 32 | typedef void (^UIAlertControllerPopoverPresentationControllerBlock) (UIPopoverPresentationController * __nonnull popover); 33 | #endif 34 | typedef void (^UIAlertControllerCompletionBlock) (UIAlertController * __nonnull controller, UIAlertAction * __nonnull action, NSInteger buttonIndex); 35 | 36 | @interface UIAlertController (Blocks) 37 | 38 | + (nonnull instancetype)showInViewController:(nonnull UIViewController *)viewController 39 | withTitle:(nullable NSString *)title 40 | message:(nullable NSString *)message 41 | preferredStyle:(UIAlertControllerStyle)preferredStyle 42 | cancelButtonTitle:(nullable NSString *)cancelButtonTitle 43 | destructiveButtonTitle:(nullable NSString *)destructiveButtonTitle 44 | otherButtonTitles:(nullable NSArray *)otherButtonTitles 45 | #if TARGET_OS_IOS 46 | popoverPresentationControllerBlock:(nullable UIAlertControllerPopoverPresentationControllerBlock)popoverPresentationControllerBlock 47 | #endif 48 | tapBlock:(nullable UIAlertControllerCompletionBlock)tapBlock; 49 | 50 | + (nonnull instancetype)showAlertInViewController:(nonnull UIViewController *)viewController 51 | withTitle:(nullable NSString *)title 52 | message:(nullable NSString *)message 53 | cancelButtonTitle:(nullable NSString *)cancelButtonTitle 54 | destructiveButtonTitle:(nullable NSString *)destructiveButtonTitle 55 | otherButtonTitles:(nullable NSArray *)otherButtonTitles 56 | tapBlock:(nullable UIAlertControllerCompletionBlock)tapBlock; 57 | 58 | 59 | + (nonnull instancetype)showActionSheetInViewController:(nonnull UIViewController *)viewController 60 | withTitle:(nullable NSString *)title 61 | message:(nullable NSString *)message 62 | cancelButtonTitle:(nullable NSString *)cancelButtonTitle 63 | destructiveButtonTitle:(nullable NSString *)destructiveButtonTitle 64 | otherButtonTitles:(nullable NSArray *)otherButtonTitles 65 | #if TARGET_OS_IOS 66 | popoverPresentationControllerBlock:(nullable UIAlertControllerPopoverPresentationControllerBlock)popoverPresentationControllerBlock 67 | #endif 68 | tapBlock:(nullable UIAlertControllerCompletionBlock)tapBlock; 69 | 70 | 71 | @property (readonly, nonatomic) BOOL visible; 72 | @property (readonly, nonatomic) NSInteger cancelButtonIndex; 73 | @property (readonly, nonatomic) NSInteger firstOtherButtonIndex; 74 | @property (readonly, nonatomic) NSInteger destructiveButtonIndex; 75 | 76 | @end 77 | -------------------------------------------------------------------------------- /UIAlertController+Blocks.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIAlertController+Blocks.m 3 | // UIAlertControllerBlocks 4 | // 5 | // Created by Ryan Maxwell on 11/09/14. 6 | // 7 | // The MIT License (MIT) 8 | // 9 | // Copyright (c) 2014 Ryan Maxwell 10 | // 11 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 12 | // this software and associated documentation files (the "Software"), to deal in 13 | // the Software without restriction, including without limitation the rights to 14 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 15 | // the Software, and to permit persons to whom the Software is furnished to do so, 16 | // subject to the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be included in all 19 | // copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 23 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 24 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 25 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | #import "UIAlertController+Blocks.h" 30 | 31 | static NSInteger const UIAlertControllerBlocksCancelButtonIndex = 0; 32 | static NSInteger const UIAlertControllerBlocksDestructiveButtonIndex = 1; 33 | static NSInteger const UIAlertControllerBlocksFirstOtherButtonIndex = 2; 34 | 35 | @interface UIViewController (UACB_Topmost) 36 | 37 | - (UIViewController *)uacb_topmost; 38 | 39 | @end 40 | 41 | @implementation UIAlertController (Blocks) 42 | 43 | + (instancetype)showInViewController:(UIViewController *)viewController 44 | withTitle:(NSString *)title 45 | message:(NSString *)message 46 | preferredStyle:(UIAlertControllerStyle)preferredStyle 47 | cancelButtonTitle:(NSString *)cancelButtonTitle 48 | destructiveButtonTitle:(NSString *)destructiveButtonTitle 49 | otherButtonTitles:(NSArray *)otherButtonTitles 50 | #if TARGET_OS_IOS 51 | popoverPresentationControllerBlock:(void(^)(UIPopoverPresentationController *popover))popoverPresentationControllerBlock 52 | #endif 53 | tapBlock:(UIAlertControllerCompletionBlock)tapBlock 54 | { 55 | UIAlertController *strongController = [self alertControllerWithTitle:title 56 | message:message 57 | preferredStyle:preferredStyle]; 58 | 59 | __weak UIAlertController *controller = strongController; 60 | 61 | if (cancelButtonTitle) { 62 | UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:cancelButtonTitle 63 | style:UIAlertActionStyleCancel 64 | handler:^(UIAlertAction *action){ 65 | if (tapBlock) { 66 | tapBlock(controller, action, UIAlertControllerBlocksCancelButtonIndex); 67 | } 68 | }]; 69 | [controller addAction:cancelAction]; 70 | } 71 | 72 | if (destructiveButtonTitle) { 73 | UIAlertAction *destructiveAction = [UIAlertAction actionWithTitle:destructiveButtonTitle 74 | style:UIAlertActionStyleDestructive 75 | handler:^(UIAlertAction *action){ 76 | if (tapBlock) { 77 | tapBlock(controller, action, UIAlertControllerBlocksDestructiveButtonIndex); 78 | } 79 | }]; 80 | [controller addAction:destructiveAction]; 81 | } 82 | 83 | for (NSUInteger i = 0; i < otherButtonTitles.count; i++) { 84 | NSString *otherButtonTitle = otherButtonTitles[i]; 85 | 86 | UIAlertAction *otherAction = [UIAlertAction actionWithTitle:otherButtonTitle 87 | style:UIAlertActionStyleDefault 88 | handler:^(UIAlertAction *action){ 89 | if (tapBlock) { 90 | tapBlock(controller, action, UIAlertControllerBlocksFirstOtherButtonIndex + i); 91 | } 92 | }]; 93 | [controller addAction:otherAction]; 94 | } 95 | 96 | #if TARGET_OS_IOS 97 | if (popoverPresentationControllerBlock) { 98 | popoverPresentationControllerBlock(controller.popoverPresentationController); 99 | } 100 | #endif 101 | 102 | [viewController.uacb_topmost presentViewController:controller animated:YES completion:nil]; 103 | 104 | return controller; 105 | } 106 | 107 | + (instancetype)showAlertInViewController:(UIViewController *)viewController 108 | withTitle:(NSString *)title 109 | message:(NSString *)message 110 | cancelButtonTitle:(NSString *)cancelButtonTitle 111 | destructiveButtonTitle:(NSString *)destructiveButtonTitle 112 | otherButtonTitles:(NSArray *)otherButtonTitles 113 | tapBlock:(UIAlertControllerCompletionBlock)tapBlock 114 | { 115 | return [self showInViewController:viewController 116 | withTitle:title 117 | message:message 118 | preferredStyle:UIAlertControllerStyleAlert 119 | cancelButtonTitle:cancelButtonTitle 120 | destructiveButtonTitle:destructiveButtonTitle 121 | otherButtonTitles:otherButtonTitles 122 | #if TARGET_OS_IOS 123 | popoverPresentationControllerBlock:nil 124 | #endif 125 | tapBlock:tapBlock]; 126 | } 127 | 128 | + (instancetype)showActionSheetInViewController:(UIViewController *)viewController 129 | withTitle:(NSString *)title 130 | message:(NSString *)message 131 | cancelButtonTitle:(NSString *)cancelButtonTitle 132 | destructiveButtonTitle:(NSString *)destructiveButtonTitle 133 | otherButtonTitles:(NSArray *)otherButtonTitles 134 | #if TARGET_OS_IOS 135 | popoverPresentationControllerBlock:(void(^)(UIPopoverPresentationController *popover))popoverPresentationControllerBlock 136 | #endif 137 | tapBlock:(UIAlertControllerCompletionBlock)tapBlock 138 | { 139 | return [self showInViewController:viewController 140 | withTitle:title 141 | message:message 142 | preferredStyle:UIAlertControllerStyleActionSheet 143 | cancelButtonTitle:cancelButtonTitle 144 | destructiveButtonTitle:destructiveButtonTitle 145 | otherButtonTitles:otherButtonTitles 146 | #if TARGET_OS_IOS 147 | popoverPresentationControllerBlock:popoverPresentationControllerBlock 148 | #endif 149 | tapBlock:tapBlock]; 150 | } 151 | 152 | #pragma mark - 153 | 154 | - (BOOL)visible 155 | { 156 | return self.view.superview != nil; 157 | } 158 | 159 | - (NSInteger)cancelButtonIndex 160 | { 161 | return UIAlertControllerBlocksCancelButtonIndex; 162 | } 163 | 164 | - (NSInteger)firstOtherButtonIndex 165 | { 166 | return UIAlertControllerBlocksFirstOtherButtonIndex; 167 | } 168 | 169 | - (NSInteger)destructiveButtonIndex 170 | { 171 | return UIAlertControllerBlocksDestructiveButtonIndex; 172 | } 173 | 174 | @end 175 | 176 | @implementation UIViewController (UACB_Topmost) 177 | 178 | - (UIViewController *)uacb_topmost 179 | { 180 | UIViewController *topmost = self; 181 | 182 | UIViewController *above; 183 | while ((above = topmost.presentedViewController)) { 184 | topmost = above; 185 | } 186 | 187 | return topmost; 188 | } 189 | 190 | @end 191 | -------------------------------------------------------------------------------- /UIAlertController+Blocks.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "UIAlertController+Blocks" 3 | s.version = "0.9.2" 4 | s.summary = "Convenience methods for UIAlertController" 5 | s.homepage = "https://github.com/ryanmaxwell/UIAlertController-Blocks" 6 | s.license = { :type => 'MIT', :file => 'LICENSE' } 7 | s.author = "Ryan Maxwell" 8 | s.source = { :git => "https://github.com/ryanmaxwell/UIAlertController-Blocks.git", :tag => '0.9.2' } 9 | s.source_files = 'UIAlertController+Blocks.{h,m}' 10 | s.requires_arc = true 11 | s.ios.deployment_target = '6.0' # 6.0 as this is a dependency for RMUniversalAlert 12 | s.tvos.deployment_target = '9.0' 13 | end 14 | --------------------------------------------------------------------------------