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
func measure(title: String, block: (() -> ()) -> ()) { | |
let startTime = CFAbsoluteTimeGetCurrent() | |
block { | |
let timeElapsed = CFAbsoluteTimeGetCurrent() - startTime | |
println("\(title):: Time: \(timeElapsed)") | |
} | |
} |
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 player = AVPlayer() | |
func playFileAtURL(url: NSURL) { | |
let asset = AVAsset.assetWithURL(url) as AVAsset | |
let duration = asset.duration | |
let durationInSeconds = CMTimeGetSeconds(duration) | |
let item = AVPlayerItem(asset: asset) | |
let params = AVMutableAudioMixInputParameters(track: asset.tracks.first! as AVAssetTrack) |
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
# Clean and build, capturing only lines containing `X.Yms` where X > 0, sorting from largest to smallest | |
# http://irace.me/swift-profiling | |
xcodebuild -workspace App.xcworkspace -scheme App clean build | grep [1-9].[0-9]ms | sort -nr > culprits.txt |
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
// MARK: - Adding a header to a single request | |
let headers: HTTPHeaders = [ | |
"X-Mashape-Key": MY_API_KEY, | |
"Accept": "application/json" | |
] | |
Alamofire.request("https://mashape-community-urban-dictionary.p.mashape.com/define?term=smh", headers: headers) | |
.responseJSON { response in | |
debugPrint(response) |