This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# xcode-build-bump.sh | |
# @desc Auto-increment the build number every time the project is run. | |
# @usage | |
# 1. Select: your Target in Xcode | |
# 2. Select: Build Phases Tab | |
# 3. Select: Add Build Phase -> Add Run Script | |
# 4. Paste code below in to new "Run Script" section | |
# 5. Drag the "Run Script" below "Link Binaries With Libraries" | |
# 6. Insure that your starting build number is set to a whole integer and not a float (e.g. 1, not 1.0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (BOOL) tabBarController:(UITabBarController *)tabBarController | |
shouldSelectViewController:(UIViewController *)viewController { | |
// http://stackoverflow.com/questions/5161730/iphone-how-to-switch-tabs-with-an-animation | |
NSUInteger controllerIndex = [self.viewControllers indexOfObject:viewController]; | |
if (controllerIndex == tabBarController.selectedIndex) { | |
return NO; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create a metafunction "has_xxx_method" that can be used | |
// to check if a class has a method called "xxx". Note the | |
// limitation: only existence of parameterless methods can | |
// be checked this way. | |
// Credits: http://stackoverflow.com/a/21827727/1525865 | |
#define HAS_METHOD_DEF(xxx) \ | |
template<typename T> \ | |
constexpr auto has_ ## xxx ## _method(int) \ | |
-> decltype(std::declval<T>(). xxx (), bool()) \ | |
{ return true; } \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
extension UIImage { | |
func imageWithInsets(insetDimen: CGFloat) -> UIImage { | |
return imageWithInset(UIEdgeInsets(top: insetDimen, left: insetDimen, bottom: insetDimen, right: insetDimen)) | |
} | |
func imageWithInset(insets: UIEdgeInsets) -> UIImage { | |
UIGraphicsBeginImageContextWithOptions( | |
CGSizeMake(self.size.width + insets.left + insets.right, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension String { | |
func isValidEmail() -> Bool { | |
guard !self.lowercaseString.hasPrefix("mailto:") else { return false } | |
guard let emailDetector = try? NSDataDetector(types: NSTextCheckingType.Link.rawValue) else { return false } | |
let matches = emailDetector.matchesInString(self, options: NSMatchingOptions.Anchored, range: NSRange(location: 0, length: self.characters.count)) | |
guard matches.count == 1 else { return false } | |
return matches[0].URL?.scheme == "mailto" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// UIAlertController+Action.swift | |
// | |
import UIKit | |
/** | |
Extension to `UIAlertController` to allow direct adding of `UIAlertAction` instances | |
*/ | |
extension UIAlertController { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package loginapp.app | |
import loginapp.views.LoginScreen | |
import tornadofx.App | |
class LoginApp : App(LoginScreen::class) |