This file contains hidden or 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 ViewController: MFMessageComposeViewControllerDelegate { | |
func showMessageComposeViewController() { | |
guard MFMessageComposeViewController.canSendText() else { | |
print("SMS services are not available") | |
return | |
} | |
let messageComposeViewController = MFMessageComposeViewController() | |
messageComposeViewController.messageComposeDelegate = self | |
messageComposeViewController.body = "Your text here" |
This file contains hidden or 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
//: Playground - noun: a place where people can play | |
import UIKit | |
import PlaygroundSupport | |
class ViewController: UIViewController { | |
lazy var tapHandler: TapHandler = TapHandler(delegate: self, view: self.view) | |
} | |
extension ViewController: TapHandlerDelegate { |
This file contains hidden or 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
// | |
// ImageProvider.swift | |
// Tuity-iOS | |
// | |
// Created by Sanket Firodiya on 7/13/16. | |
// Copyright © 2016 Tuity. All rights reserved. | |
// | |
import UIKit |
This file contains hidden or 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 | |
extension UITextField { | |
func containsOnlyNumbers(string: String, maximumDecimalPlaces: NSInteger, maximumValue: NSInteger) -> Bool { | |
// Check that textfield only contains allowed number of decimal places (this can also be done in regex, but avoiding so that is easier to understand and debug | |
if string.characters.contains(".") { | |
if string.componentsSeparatedByString(".").count > 2 { | |
return false | |
} else { | |
let newStringSplitAtDecimal = string.componentsSeparatedByString(".") |
This file contains hidden or 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
expr @import UIKit |
This file contains hidden or 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
# Uncrustify 0.61 | |
# | |
# General options | |
# | |
# The type of line endings | |
newlines = auto # auto/lf/crlf/cr | |
# The original size of tabs in the input |
This file contains hidden or 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
NSString *sourceString = [[NSThread callStackSymbols] objectAtIndex:1]; | |
// Example: 1 UIKit 0x00540c89 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1163 | |
NSCharacterSet *separatorSet = [NSCharacterSet characterSetWithCharactersInString:@" -[]+?.,"]; | |
NSMutableArray *array = [NSMutableArray arrayWithArray:[sourceString componentsSeparatedByCharactersInSet:separatorSet]]; | |
[array removeObject:@""]; | |
NSLog(@"Stack = %@", [array objectAtIndex:0]); | |
NSLog(@"Framework = %@", [array objectAtIndex:1]); | |
NSLog(@"Memory address = %@", [array objectAtIndex:2]); | |
NSLog(@"Class caller = %@", [array objectAtIndex:3]); |
This file contains hidden or 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)isBSTValid { | |
return [self validate:self.root withMin:MIN.INTEGER withMax:MAX.INTEGER]; | |
} | |
- (BOOL)validate:(Node *)root withMin:(NSUInteger)min withMax:(NSUInteger)max { | |
if (root.value <= min || root.value >= max) { | |
return NO; | |
} |
This file contains hidden or 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)isBSTBalanced:(Node *)root { | |
return ([self maxHeight:root] - [self minHeight:root] <= 1); | |
} | |
- (NSUInteger)maxHeight:(Node *)root { | |
if (root == null) { | |
return 0; | |
} | |
return MAX([self maxHeight:root.leftNode], [self maxHeight:root.rightNode]) + 1; |
NewerOlder