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
| //AVFoundation Method | |
| let size = AVMakeRectWithAspectRatioInsideRect(image.size, contentFrame).size | |
| //Helper Methods | |
| func sizeWithAspectRatioInsideRect(aspectRatio: CGSize, boundingRect: CGRect) -> CGSize { | |
| let widthRatio = boundingRect.size.width / aspectRatio.width | |
| let heightRatio = boundingRect.size.height / aspectRatio.height | |
| let ratio = min(widthRatio, heightRatio) | |
| let transform = CGAffineTransformMakeScale(ratio, ratio) | |
| return CGSizeApplyAffineTransform(aspectRatio, transform) |
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
| // | |
| // DarwinNotificationHelper.h | |
| // MeatCooker | |
| // | |
| // Created by Jack Wu on 2015-02-02. | |
| // Copyright (c) 2015 Ray Wenderlich. 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
| // | |
| // DarwinNotificationHelper.m | |
| // MeatCooker | |
| // | |
| // Created by Jack Wu on 2015-02-02. | |
| // Copyright (c) 2015 Ray Wenderlich. All rights reserved. | |
| // | |
| #import "DarwinNotificationHelper.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 <Foundation/Foundation.h> | |
| #import <WatchKit/WatchKit.h> | |
| @interface AYWatchDeviceCacheHelper : NSObject | |
| + (void)addImageToCache:(UIImage *)image | |
| imageName:(NSString *)name; | |
| + (BOOL)cacheContainsImageName:(NSString *)imageName; | |
| @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 "AYWatchDeviceCacheHelper.h" | |
| @implementation AYWatchDeviceCacheHelper | |
| + (void)addImageToCache:(UIImage *)image | |
| imageName:(NSString *)name | |
| { | |
| WKInterfaceDevice *device = [WKInterfaceDevice currentDevice]; | |
| while ([device addCachedImage:image name:name] == NO) { | |
| BOOL success = [[self class] removeRandomImageFromCache]; |
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 utf8str: NSData = str.dataUsingEncoding(NSUTF8StringEncoding) | |
| let utf8str = str.dataUsingEncoding(NSUTF8StringEncoding) | |
| let base64Encoded:NSString = utf8str.base64EncodedStringWithOptions(NSDataBase64EncodingOptions.fromRaw(0)!) | |
| let base64Encoded = utf8str.base64EncodedStringWithOptions(NSDataBase64EncodingOptions.fromRaw(0)!) | |
| let data: NSData = NSData(base64EncodedString: base64Encoded, options: NSDataBase64DecodingOptions.fromRaw(0)!) | |
| let data = NSData(base64EncodedString: base64Encoded, options: NSDataBase64DecodingOptions.fromRaw(0)!) | |
| let base64Decoded: NSString = NSString(data: data, encoding: NSUTF8StringEncoding) |
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 AVFoundation | |
| if let asset = AVAsset(URL: videoURL) { | |
| let durationSeconds = CMTimeGetSeconds(asset.duration) | |
| let generator = AVAssetImageGenerator(asset: asset) | |
| generator.appliesPreferredTrackTransform = true | |
| let time = CMTimeMakeWithSeconds(durationSeconds/3.0, 600) | |
| var thumbnailImage: CGImageRef |
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
| protocol ExcutableQueue { | |
| var queue: dispatch_queue_t { get } | |
| } | |
| extension ExcutableQueue { | |
| func execute(closure: () -> Void) { | |
| dispatch_async(queue, closure) | |
| } | |
| } |
OlderNewer