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
CGFloat height = self.tableView.bounds.size.height - [UIApplication sharedApplication].statusBarFrame.size.height; | |
height = height - self.navigationController.navigationBar.frame.size.height; | |
height = height - self.tabBarController.tabBar.bounds.size.height; |
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
// Random number between 0 and n | |
let n = 42 | |
let randomNumber = Int(arc4random_uniform(n)) | |
// Instantiate a view controller that exists in a storyboard | |
let storyboardName = "Main" | |
let storyboard = UIStoryboard(name: storyboardName, bundle: nil) | |
let storyboardIdForViewController = "MyVC" // Specified in IB on the specific view controller instance | |
let myVc: MyViewController = storyboard.instantiateViewControllerWithIdentifier(storyboardIdForViewController) as! MyViewController |
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 UIView | |
{ | |
func shake() | |
{ | |
let shakeAngle = (5 * M_PI) / 360 | |
let shakeRotation = CAKeyframeAnimation(keyPath: "transform.rotation") |
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/bash | |
# | |
# Opens any xcworkspace or xcodeproj found in the current directory in Xcode. | |
# | |
openfile () ( | |
file="$1" | |
echo "Opening $file"; | |
open $file; | |
) |
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
int main(int argc, char *argv[]) { | |
@autoreleasepool { | |
@try { | |
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); | |
} @catch (NSException *exception) { | |
#if DEBUG | |
NSLog(@"\n\n********************"); | |
NSLog(@"UNHANDLED EXCEPTION:"); | |
NSLog(@"%@", exception); | |
NSLog(@"Stack trace: %@", [exception callStackSymbols]); |
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 | |
struct ImageStore { | |
static func delete(imageNamed name: String) { | |
guard let imagePath = ImageStore.path(for: name) else { | |
return | |
} | |
try? FileManager.default.removeItem(at: imagePath) |
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 RxSwift | |
func submit(number: Int) { | |
let validateAndPerformServiceCallIfSuccessful = performValidation(numberThatShouldBeEven: number) | |
.flatMap { () -> Observable<Void> in | |
print("Validated successfully") | |
return performServiceCall() // For any .next events from performValidation, perform the service call | |
} | |
// By subscribing, validation is performed and the service call is executed for any .next events from performValidation |
OlderNewer