| Path | Protocol | 
|---|---|
| /swift/stdlib/public/core/AnyHashable.swift:16 | _HasCustomAnyHashableRepresentation | 
| /swift/stdlib/public/core/BidirectionalCollection.swift:21 | _BidirectionalIndexable | 
| /swift/stdlib/public/core/BridgeObjectiveC.swift:19 | _ObjectiveCBridgeable | 
| /swift/stdlib/public/core/Collection.swift:20 | _IndexableBase | 
| /swift/stdlib/public/core/Collection.swift:176 | _Indexable | 
| /swift/stdlib/public/core/CompilerProtocols.swift:193 | _ExpressibleByBuiltinIntegerLiteral | 
| /swift/stdlib/public/core/CompilerProtocols.swift:240 | _ExpressibleByBuiltinFloatLiteral | 
| /swift/stdlib/public/core/CompilerProtocols.swift:283 | _ExpressibleByBuiltinBooleanLiteral | 
  
    
      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
    
  
  
    
  | #!/usr/bin/env bash | |
| # | |
| # Author: Stefan Buck | |
| # License: MIT | |
| # https://gist.github.com/stefanbuck/ce788fee19ab6eb0b4447a85fc99f447 | |
| # | |
| # | |
| # This script accepts the following parameters: | |
| # | |
| # * owner | 
  
    
      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 DispatchQueue { | |
| class func mainSyncSafe(execute work: () -> Void) { | |
| if Thread.isMainThread { | |
| work() | |
| } else { | |
| DispatchQueue.main.sync(execute: work) | |
| } | |
| } | |
| class func mainSyncSafe<T>(execute work: () throws -> T) rethrows -> T { | 
  
    
      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
    
  
  
    
  | @implementation CMFWallpaper | |
| + (void)setImage:(UIImage *)image { | |
| NSAssert([PHPhotoLibrary authorizationStatus] == PHAuthorizationStatusAuthorized, @"access to photos is needed to set the wallpaper"); | |
| NSString *path; | |
| #if TARGET_OS_SIMULATOR | |
| path = @"/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/PhotoLibrary.framework"; | |
| #else | |
| path = @"/System/Library/PrivateFrameworks/PhotoLibrary.framework"; | 
Update: https://www.cyanhall.com/posts/notes/7.homebrew-cheatsheet/#java
on El Capitan, after installing the brew...
$ brew update
$ brew tap caskroom/cask
$ brew install Caskroom/cask/java
And Java 8 will be installed at /Library/Java/JavaVirtualMachines/jdk1.8.xxx.jdk/
在 Xcode 里下载文件真的是一种折磨, 特别是每次 Xcode 大版本更新都会遇到新的下载内容. 经过一翻周折, 本人找到一个方法可以轻松快速便捷地下载和安装对应的 Simulator 和 Doc 文件
- 在 Mac 下, 打开 Xcode, 进入 Preference 中的 Downloads 面板
- 点击任意的下载按钮
- 打开系统帮助工具 Console
- 稍等一会儿, 在 Xcode 里取消下载, 然后你会在 Console 里面看到对应的下载地址 (对应的 Cosnole Message 是 (DVTDownloadable: Download Cancelled. Downloadable: ...) 之类的)
- 复制对应的链接地址, 到某雷或者任何比 Xcode 下载快的工具里
- 等待下载完成, 进入 /Users/#{Username}/Library/Caches
- Array 是 value type,使用 structs 实现
- 数据类型没有隐式转换
- 对于 String,count() 的复杂度是 O(n),每一个 Character 都是 unicode scalars 的序列
- raw values 和 associated values 的区别
- 如果必要,对于实现了 _ObjectiveCBridgeable 的 value types 会被自动桥接成 reference types
- 讲一下 unowned 和 weak 的区别
- 改 struct 的属性的方法名前要加 mutating,但如果这个 struct 用 let 声明的,改不了。修正:网友指出用 nonmutating set 也可以改属性。
- nil 和 .None 的区别
- capture list in closure
- 举一个 guard ... where 的例子
  
    
      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
    
  
  
    
  | // | |
| // NSNull+LCFMessageForwarding.h | |
| // NSNull | |
| // | |
| // Created by leichunfeng on 15/12/22. | |
| // Copyright © 2015年 leichunfeng. All rights reserved. | |
| // | |
| #import <Foundation/Foundation.h> | 
  
    
      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 | |
| // for-in | |
| func checkForIn(array: [Int], dict: [Int: String]) { | |
| for num in array where dict[num] != nil { | |
| num | |
| } | |
| } | |
| checkForIn([1,2,3,4], dict: [1:"one", 2:"two"]) | 
  
    
      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 | |
| // Interactive Playground Alert Utilities | |
| public struct WindowManager { | |
| internal static var screen: NSScreen! = NSScreen.mainScreen() | |
| internal static var activationToken: dispatch_once_t = 0 | |
| internal static func buildWindow() -> NSWindow { | |
| dispatch_once(&WindowManager.activationToken) { | |
| NSApplication.sharedApplication().setActivationPolicy(.Regular) // show icon in dock |