This file contains 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 num = 1234 | |
let numList = "\(num)".characters.flatMap { Int("\($0)") } | |
// let numList = String(num).characters.flatMap { Int(String($0)) } | |
print(numList) | |
// [1, 2, 3, 4] |
This file contains 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
// storyboardに置いたimageViewからCIImageを生成する | |
let image = CIImage(CGImage: self.sampleImageView.image?.CGImage) | |
// 顔認識なのでTypeをCIDetectorTypeFaceに指定する | |
let detector = CIDetector(ofType: CIDetectorTypeFace, context: nil, options: [CIDetectorAccuracy: CIDetectorAccuracyHigh]) | |
// 取得するパラメーターを指定する | |
let options = [CIDetectorSmile : true, CIDetectorEyeBlink : true] | |
// 画像から特徴を抽出する |
This file contains 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
-(IBAction)postToTwitter{ | |
// ServiceTypeをTwitterに設定 | |
NSString *serviceType = SLServiceTypeTwitter; | |
// Twitterが利用可能かチェック | |
if ([SLComposeViewController isAvailableForServiceType:serviceType]) { | |
// SLComposeViewControllerを初期化・生成 | |
SLComposeViewController *twitterPostVC = [[SLComposeViewController alloc] init]; |
This file contains 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
// カメラを起動する | |
-(IBAction)launchCamera{ | |
// 画像の取得先をカメラに設定 | |
UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera; | |
// カメラが使用可能かどうか判定する | |
if ([UIImagePickerController isSourceTypeAvailable:sourceType]) { | |
// UIImagePickerControllerを初期化・生成 |
This file contains 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
// フォトライブラリを開く | |
-(IBAction)openLibrary{ | |
// 画像の取得先をフォトライブラリに設定 | |
UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypePhotoLibrary; | |
// フォトライブラリを使用可能かどうか判定する | |
if ([UIImagePickerController isSourceTypeAvailable:sourceType]) { | |
// UIImagePickerControllerを初期化・生成 |
NewerOlder