Some of the major topics covered in this section include:
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
| switch newValue { | |
| // snip | |
| case .Some(let number as NSNumber): | |
| switch number { | |
| case _ where CFNumberIsFloatType(number) != 0: | |
| self = .JSONDouble(number.doubleValue) | |
| case _ where CFNumberGetType(number) == .CharType || CFGetTypeID(number) == CFBooleanGetTypeID(): | |
| self = .JSONBool(number.boolValue) | |
| default: | |
| self = .JSONInt(number.integerValue) |
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; | |
| NS_ASSUME_NONNULL_BEGIN | |
| @interface MyOneClass : NSObject @end | |
| @implementation MyOneClass; @end | |
| @interface MyOtherClass : MyOneClass @end | |
| @implementation MyOtherClass; @end |
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 | |
| // MARK: String | |
| extension String { | |
| func convert(#index: Int) -> Index? { | |
| let utfIndex = advance(utf16.startIndex, index, utf16.endIndex) | |
| return utfIndex.samePositionIn(self) | |
| } |
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
| defaults write com.apple.dt.Xcode IDEFileTemplateChooserAssistantSelectedTemplateCategory "Source" | |
| defaults write com.apple.dt.Xcode IDEFileTemplateChooserAssistantSelectedTemplateName "Cocoa Touch Class" | |
| defaults write com.apple.dt.Xcode IDEFileTemplateChooserAssistantSelectedTemplateSection "com.apple.platform.iphoneos" |
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
| Swift reStructured text: | |
| Indentation (four space tabs) | |
| Bold ("**bold**") | |
| Italic ("*italics*") | |
| Literals (``double back-quotes``) | |
| Parameters (:param:) | |
| Return types (:returns:) | |
| Definition lists (basically lists with indentation) |
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 Cocoa; | |
| @import AVFoundation; | |
| @interface AppDelegate : NSObject <NSApplicationDelegate> | |
| @end | |
| static NSArray * metadataFromAssetDictionary(NSArray *sourceMetadata, NSDictionary *metadataDict) | |
| { | |
| NSMutableDictionary *mutableMetadataDict = [NSMutableDictionary dictionaryWithDictionary:metadataDict]; | |
| NSMutableArray *newMetadata = [NSMutableArray array]; |
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 Cocoa; | |
| @interface NSViewController (AuxiliaryWindow) | |
| - (void)zw_presentViewControllerAsAuxiliaryWindow:(NSViewController *)viewController; | |
| @end |
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
| #!/bin/sh | |
| # I first mitigated dupes by only having one label per message in Gmail. | |
| # `imapsync` is https://github.com/imapsync/imapsync | |
| imapsync —host1 imap.gmail.com —user1 <#Gmail address#> —password1 <#Gmail app password#> —ssl1 —port1 993 —host2 mail.messagingengine.com —user2 <#FastMail email#> —password2 <#FastMail one-time password#> —ssl2 —port2 993 —syncinternaldates —noauthmd5 —split1 100 —split2 100 —exclude ‘^\[Gmail\](?!/)’ —exclude All Mail —exclude Spam —exclude Trash —allowsizemismatch |
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 | |
| public protocol ErrorRepresentable { | |
| class var domain: String { get } | |
| } | |
| public protocol ErrorCodeRepresentable: ErrorRepresentable, RawRepresentable { } | |
| public protocol LocalizedErrorRepresentable: ErrorRepresentable { | |
| typealias ErrorCode: SignedIntegerType |