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
/* | |
The layout (notice how button is 50% on top of the collection view | |
while still added to the ContainerView) | |
|----------------------------------------------------| | |
| ContainerView | | |
| ------------------------------------------------ | | |
| | CollectionView | | | |
| | ___________ | | | |
| | | | | | |
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
/// The Medium artcile, discussing the approach | |
/// https://medium.com/@euginedubinin/swift-useful-autoclosure-when-presenting-uialertviewcontroller-b592d1643a50#.kx0fuqm1x | |
final class NoteViewController: UIViewController { | |
// ... set up target-action for an Edit UIButton somewhere here ... | |
private dynamic func handleEditButton() { | |
presentEditConfirmationDialog(onEdit: self.editArticle(), | |
onCancel: () ) /* assuming you have nothing to do upon cancellation */ |
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 Foundation | |
private let justAOneTimeThing: () = { | |
print("\(GlobalOnceClass.self): Do This once") | |
}() | |
public final class GlobalOnceClass { | |
public init() { | |
} |
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
// Swift 3 | |
extension CharacterSet { | |
/// Test for membership of a particular `UnicodeScalar?` in the `CharacterSet`. | |
/// - important: This `contains(_:)` oveload works with `Optional<UnicodeScalar>` | |
/// | |
/// Consider the following example: | |
/// ```` | |
/// let flowermoji = "💐" | |
/// let ucscalar = UnicodeScalar(flowermoji.utf16.last!) |
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 <Foundation/Foundation.h> | |
@interface NSTimeZone (SBTExtensions) | |
/*! | |
@brief Convert seconds, represented as a string to the timezone. Returns nil when conversion failed. | |
The method covers both, integers and floating point numbers. | |
*/ | |
+ (nullable instancetype)timeZoneForSecondsFromGMTString:(nonnull NSString *)secondsString; | |
@end |
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
// | |
// Login via FBSDK | |
// | |
- (void)connectFacebookAccountWithCompletionHandler:(void (^)(NSError *))completionHandler | |
{ | |
NSArray *readPermissions = @[@"public_profile", @"user_friends", @"email", @"user_likes"]; | |
if (![FBSDKAccessToken currentAccessToken]) { | |
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init]; | |
[login logInWithReadPermissions:readPermissions |
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
#!/bin/sh | |
releaseConfig="Release" | |
debugConfiguration="Debug" | |
adhocConfiguration="AdHoc" | |
if [ "$adhocConfiguration" = "${CONFIGURATION}" ] || [ "$releaseConfig" = "${CONFIGURATION}" ]; then | |
echo "Running Crashlytics" | |
"${PODS_ROOT}/Fabric/Fabric.framework/run" <your_api_key> <your_build_secret> | |
else |
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
var input: String | |
// CASE 1 | |
func validateWithError(error: NSErrorPointer) -> Bool { | |
var regexpError: NSError? | |
let regexp: NSRegularExpression? | |
do { | |
regexp = try NSRegularExpression(pattern: "[a-zA-Z0-9_]{4,}", options:[]) | |
} catch let error as NSError { | |
regexpError = error |
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
private func isAlertExist() -> Bool { | |
for window in UIApplication.sharedApplication().windows { | |
if let w = window as? UIWindow where w.subviews.count > 0 { | |
for subview in w.subviews { | |
if let s = subview as? UIAlertView { | |
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 "MYAppDelegate.h" | |
@interface MYAppDelegate () <UISplitViewControllerDelegate> | |
/... | |
@property (nonatomic, strong) UISplitViewController* splitViewController; | |
@end | |
@implementation MYAppDelegate | |
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { |
NewerOlder