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 application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { | |
// Override point for customization after application launch. | |
// アプリウィンドウを設定します。 | |
self.window = UIWindow(frame: UIScreen.main.bounds) | |
// ウィンドウをヴィジブルにします。 | |
self.window?.makeKeyAndVisible() | |
// ウィンドウの rootViewController を viewController に設定します。 |
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
let testString = "test" | |
let testFlag = true | |
let testInt = 1 | |
let testArray = [testString, testFlag, testInt] |
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
let randomIntArray = [Int](count: 10, repeatedValue: 0).map { (some: Int) -> Int in | |
let randomUInt = arc4random_uniform(100) // 0 ..< 100 の乱数を作る | |
return Int(randomUInt) - 50 | |
} |
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
int arrayA[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; | |
int arrayB[10]; | |
for (int i = 0; i < 10; i++) { | |
arrayB[i] = arrayA[i] * arrayA[i]; | |
} |
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
// Playground - noun: a place where people can play | |
import UIKit | |
// オリジナル画像を読み込もう(ファイル名の設定忘れないでね) | |
let baseImage = UIImage(named: "image.png")! | |
let baseCIImage = CIImage(image: baseImage) | |
// Core Image フィルターを #00FFFF の色で設定する | |
let filterColor = CIColor(red: 0, green: 1, blue: 1) |
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
class ViewController: UIViewController { | |
var settings: UserSettings | |
init() { | |
self.settings = UserSettings(a: 0, b: false, c: "NO") | |
super.init(nibName: nil, bundle: nil) | |
} |
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
let a = 0 | |
switch a { | |
case Int.min ..< 0: | |
print("負数") | |
case 0: | |
print("零") | |
case 1 ... Int.max: | |
print("正数") |
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 CallbackButton: UIButton { | |
private var action: (() -> Void)? | |
init(frame: CGRect, action: (() -> Void)? = nil) { | |
self.action = action |
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
let dict = [1: 2, 3: 4] | |
let key = 1 | |
if let value = dict[key] { | |
print(value) | |
} |
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 getByteArrayFromImage(imageRef: CGImageRef) -> [UInt8] { | |
let data = CGDataProviderCopyData(CGImageGetDataProvider(imageRef)) | |
let length = CFDataGetLength(data) | |
var rawData = [UInt8](count: length, repeatedValue: 0) | |
CFDataGetBytes(data, CFRange(location: 0, length: length), &rawData) | |
return rawData | |
} |
OlderNewer