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
import UIKit | |
struct AStruct { | |
let anInt: Int | |
let aString: String | |
} | |
var array: [AStruct] |
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
import UIKit | |
import AVFoundation | |
class ImageViewWithGradient: UIImageView | |
{ | |
let myGradientLayer: CAGradientLayer | |
override init(frame: CGRect) | |
{ |
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
import UIKit | |
import AVFoundation | |
let dictionary = ["aKey": "aValue", "anotherKey": "anotherValue"] | |
let theJSONData = NSJSONSerialization.dataWithJSONObject( | |
dictionary , | |
options: NSJSONWritingOptions.PrettyPrinted, | |
error: nil) | |
let theJSONText = NSString(data: theJSONData!, | |
encoding: NSASCIIStringEncoding) |
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
Using Core Foundation (CF) objects in ARC | |
ARC makes most aspects of memory management easier, but managing CF objects is still up to you, and converting | |
between NSObjects and CFObjects is actually more complicated. | |
If you create a CF object that follows the "Create Rule" (you own an object that is created with a method with | |
"create" or "copy" its name) you have to release it. | |
In ARC, that's still 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
UIBezierPath *aPath = [UIBezierPath UIBezierPath]; | |
[aPath moveToPoint: CGPointMake(0, 0); | |
[aPath addLineToPoint: CGPointMake(0, 200)]; | |
[aPath addLineToPoint: CGPointMake(200, 200)]; | |
[aPath addLineToPoint: CGPointMake(200, 0)]; | |
[[aPath closePath]; |