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 ObjC: NSObject | |
+ (BOOL)catchException:(void(^)(void))tryBlock error:(__autoreleasing NSError **)error; | |
@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
// From https://albertodebortoli.com/2018/03/12/easy-view-controller-unit-testing/ | |
import XCTest | |
import UIKit | |
class ControllerLifecycle<T: UIViewController> | |
{ | |
private lazy var this = type(of: self).self | |
private var rootWindow: UIWindow? | |
var rootController: T? { |
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
// I saw this trick in “Do you often forget [weak self], here is a solution” | |
// https://medium.com/anysuggestion/preventing-memory-leaks-with-swift-compile-time-safety-49b845df4dc6 | |
import UIKit | |
class ViewController: UIViewController { | |
// move this variable inside viewDidLoad to see it being released | |
let downloader = Downloader() | |
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
#!/usr/bin/perl | |
# | |
# PackageApplication | |
# | |
# Copyright (c) 2009-2012 Apple Inc. All rights reserved. | |
# | |
# Package an iPhone Application into an .ipa wrapper | |
# | |
use Pod::Usage; |
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> | |
#undef X | |
typedef void (^salute_t)(); | |
@interface Person : NSObject | |
@property (nonatomic,copy) NSString *name; | |
@property (nonatomic,copy) salute_t salute; |
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
enum Colors: Int64 | |
{ | |
case black = 0x000000ff | |
case white = 0xffffffff | |
func color() -> UIColor | |
{ | |
let red = CGFloat((self.rawValue >> 24) & 0xff) / 255.0 | |
let green = CGFloat((self.rawValue >> 16) & 0xff) / 255.0 | |
let blue = CGFloat((self.rawValue >> 8) & 0xff) / 255.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
import UIKit | |
import PluggableApplicationDelegate | |
@UIApplicationMain | |
class AppDelegate: PluggableApplicationDelegate | |
{ | |
override var services: [ApplicationService] { | |
return [ | |
LoggerApplicationService() | |
] |
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
#!/usr/bin/env bash | |
if [[ ! ( # any of the following are not true | |
# 1st arg is an existing regular file | |
-f "$1" && | |
# ...and it has a .ipa extension | |
"${1##*.}" == "ipa" && | |
# 2nd arg is an existing regular file | |
-f "$2" && | |
# ...and it has an .mobileprovision extension |
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 | |
extension Optional | |
{ | |
@discardableResult | |
func ifSome(_ handler: (Wrapped) -> Void) -> Optional { | |
switch self { | |
case .some(let wrapped): handler(wrapped); return self | |
case .none: return self | |
} |