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 "ViewController.h" | |
| @interface ViewController () | |
| @property (nonatomic) id webview; | |
| @end | |
| @implementation ViewController | |
| - (void)viewDidLoad { | |
| [super viewDidLoad]; |
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 UIKit | |
| class C { | |
| var view:UIView | |
| init(view:UIView) { | |
| self.view = view | |
| } | |
| } | |
| var v = UIView() | |
| var c = C(view:v) |
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
| print("installed CodePiece.app via AppStore ! 🎉") |
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
| NSLog(@"%s", __FUNCTION__); | |
| UIDeviceOrientation deviceOrientation = [[UIDevice currentDevice]orientation]; | |
| UIInterfaceOrientation currentOrientation = [[UIApplication sharedApplication]statusBarOrientation]; | |
| NSLog(@"%@", UIDeviceOrientationIsLandscape(deviceOrientation)?@"deviceLand":@"devicePort"); | |
| NSLog(@"%@", UIInterfaceOrientationIsLandscape(currentOrientation)?@"currentStatusBarLand":@"currentStatusBarPort"); |
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
| func test2(b:(Int) -> Any) { | |
| } | |
| test2 {(a:Int) in | |
| return 0 | |
| } | |
| test2 {(a:Any) in // <= does compile | |
| return 0 | |
| } |
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
| public struct NSTrackingAreaOptions : OptionSetType { | |
| public init(rawValue: UInt) | |
| /* Type of tracking area. You must specify one or more type from this list in the NSTrackingAreaOptions argument of -initWithRect:options:owner:userInfo: */ | |
| public static var MouseEnteredAndExited: NSTrackingAreaOptions { get } // owner receives mouseEntered when mouse enters area, and mouseExited when mouse leaves area | |
| public static var MouseMoved: NSTrackingAreaOptions { get } // owner receives mouseMoved while mouse is within area. Note that mouseMoved events do not contain userInfo | |
| public static var CursorUpdate: NSTrackingAreaOptions { get } // owner receives cursorUpdate when mouse enters area. Cursor is set appropriately when mouse exits area | |
| /* When tracking area is active. You must specify one of the following in the NSTrackingAreaOptions argument of -initWithRect:options:owner:userInfo: */ | |
| public static var ActiveWhenFirstResponder: NSTrackingAreaOptions { get } // owner receiv |
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
| func exec(closure:Int->Void) { | |
| closure(4) | |
| } | |
| exec {number in | |
| print(number) // 4 | |
| let number = 3 | |
| print(number) // 3 | |
| } |
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
| func fib(idx:Int) { | |
| let result = (0...idx).reduce([Int]()) {(var t, e) in | |
| t.append(t.count < 2 ? e : t[t.count-2] + t[t.count-1]) | |
| return t | |
| }.last | |
| print(result ?? "no value found") | |
| } | |
| _ = Process.arguments | |
| .map{Int($0)}.flatMap{$0}.filter{$0>=0}.map(fib) |
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
| struct Book { | |
| enum BookType: String { | |
| case 単行本, 電子書籍 | |
| } | |
| let bookType:BookType | |
| let price:Int | |
| } | |
| print(Book.BookType.単行本) // "単行本" |
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 $ find . -name "*rst" -print0 | xargs -0 wc -l | |
| 37721 total |