up vote 387 down vote accepted I'd do it with cherry-pick -n (--no-commit) which lets you inspect (and modify) the result before committing:
git cherry-pick -n
//MARK: - | |
//MARK: Private | |
class JobQueueCenter {} | |
//MARK: - | |
//MARK: Public API | |
extension JobQueueCenter { | |
static let current = JobQueueCenter() |
protocol Job : NSCoding { | |
var retryableCount: Int { get } | |
func run() | |
} |
//MARK: - | |
//MARK: Private | |
class JobQueueCenter { | |
fileprivate let storageAccessQueue = DispatchQueue(label: "com.JobQueueCenter.storageAccessQueue") | |
fileprivate lazy var storage: JobQueueStorage = { ... } | |
fileprivate func serializeStorage() {} | |
fileprivate init() { | |
NotificationCenter.default.addObserver(self, selector: #selector(tryPersist), name: .UIApplicationDidReceiveMemoryWarning, object: nil) |
protocol JobQueueStorage : NSCoding { | |
func enqueue(_ element: Job) | |
func dequeue()-> Job? | |
} |
class DocumentUploadService : NSObject { | |
var document: Data | |
init(document: Data) { | |
self.document = document | |
super.init() | |
} | |
func execute(complete: @escaping (Bool)->Void) { | |
//do something with the document argument |
func upload(fileToUpload: Data) { | |
//this | |
DocumentUploadService(document: fileToUpload).execute { | |
... | |
} | |
//becomes that | |
let job = DocumentUploadService(document: fileToUpload) | |
JobQueueCenter.current.enqueue(job: job) | |
} |
class DocumentUploadService : NSObject, Job { | |
//MARK: - | |
//MARK: Logic | |
var document: Data | |
init(document: Data) { ... } | |
func execute(complete: @escaping (Bool)->Void) { ... } | |
//MARK: - |
# OS X | |
.DS_Store | |
# Xcode | |
xcuserdata/ | |
*.xccheckout | |
# AppCode | |
.idea/ |
public struct TextSize { | |
fileprivate struct CacheEntry: Hashable { | |
let text: String | |
let font: UIFont | |
let width: CGFloat | |
let insets: UIEdgeInsets | |
fileprivate var hashValue: Int { | |
return text.hashValue ^ Int(width) ^ Int(insets.top) ^ Int(insets.left) ^ Int(insets.bottom) ^ Int(insets.right) |