This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.
To capture the video (filesize: 19MB), using the free "QuickTime Player" application:
| source ~/.bash_profile | |
| hash oclint &> /dev/null | |
| if [ $? -eq 1 ]; then | |
| echo >&2 "oclint not found, analyzing stopped" | |
| exit 1 | |
| fi |
| // UIFont+Utility.h | |
| // UIFont+Utility.[h|m] is (C) Kerri Shotts 2013, and released under an MIT license. | |
| #import <UIKit/UIKit.h> | |
| /** | |
| * | |
| * PKFontNormal = no modifications to the font; i.e., -Regular, -Roman, -Book, etc. | |
| * PKFontBold = bold font desired (if possible); i.e., -Bold, -Black, -Heavy, etc. | |
| * PKFontItalic = italic font desired (if possible); i.e., -Italic, -Oblique, etc. |
| http://devstreaming.apple.com/videos/wwdc/2013/710xfx3xn8197k4i9s2rvyb/710/710-HD.mov?dl=1 | |
| http://devstreaming.apple.com/videos/wwdc/2013/202xdx2x47ezp1wein/202/202-HD.mov?dl=1 | |
| http://devstreaming.apple.com/videos/wwdc/2013/200xdx2x35e1pxiinm/200/200-HD.mov?dl=1 | |
| http://devstreaming.apple.com/videos/wwdc/2013/413xdx5x97itb5ek4yex3r7/413/413-HD.mov?dl=1 | |
| http://devstreaming.apple.com/videos/wwdc/2013/612xax4xx65z1ervy5np1qb/612/612-HD.mov?dl=1 | |
| http://devstreaming.apple.com/videos/wwdc/2013/221xex4xxohbllf4hblyngt/221/221-HD.mov?dl=1 | |
| http://devstreaming.apple.com/videos/wwdc/2013/220xbx4xipaxfd1tggxuoib/220/220-HD.mov?dl=1 | |
| http://devstreaming.apple.com/videos/wwdc/2013/711xcx4x8yuutk8sady6t9f/711/711-HD.mov?dl=1 | |
| http://devstreaming.apple.com/videos/wwdc/2013/404xbx2xvp1eaaqonr8zokm/404/404-HD.mov?dl=1 | |
| http://devstreaming.apple.com/videos/wwdc/2013/505xbx4xrgmhwby4oiwkrpp/505/505-HD.mov?dl=1 |
| func XCTAssertOptional(expression: @autoclosure () -> AnyObject?, _ message: String? = nil) { | |
| let evaluatedExpression:AnyObject? = expression() | |
| if evaluatedExpression == nil { | |
| if let messageValue = message { | |
| XCTFail(messageValue) | |
| } | |
| else { | |
| XCTFail("Optional asertion failed: \(evaluatedExpression)") | |
| } |
| // | |
| // main.swift | |
| // Routes | |
| // | |
| // Created by Chris Eidhof on 17/08/14. | |
| // Copyright (c) 2014 Chris Eidhof. All rights reserved. | |
| // | |
| import Foundation |
When Swift was first announced, I was gratified to see that one of the (few) philosophies that it shared with Objective-C was that exceptions should not be used for control flow, only for highlighting fatal programming errors at development time.
So it came as a surprise to me when Swift 2 brought (What appeared to be) traditional exception handling to the language.
Similarly surprised were the functional Swift programmers, who had put their faith in the Haskell-style approach to error handling, where every function returns an enum (or monad, if you like) containing either a valid result or an error. This seemed like a natural fit for Swift, so why did Apple instead opt for a solution originally designed for clumsy imperative languages?
I'm going to cover three things in this post:
| #import <UIKit/UIKit.h> | |
| #import <AVFoundation/AVFoundation.h> | |
| @interface VisualizerView : UIView | |
| @property (strong, nonatomic) AVAudioPlayer *audioPlayer; | |
| @property (nonatomic, assign) NSInteger numberOfBars; | |
| @end |
| import Cocoa | |
| // for-in | |
| func checkForIn(array: [Int], dict: [Int: String]) { | |
| for num in array where dict[num] != nil { | |
| num | |
| } | |
| } | |
| checkForIn([1,2,3,4], dict: [1:"one", 2:"two"]) |