Skip to content

Commit 99fe35f

Browse files
committed
minor param improvements
1 parent 04352ac commit 99fe35f

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

bk2ch28AppendixB/bk2ch40AppendixB/ViewController.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ extension NSLayoutConstraint {
5858
}
5959
}
6060

61-
func imageOfSize(size:CGSize, opaque:Bool = false, closure:() -> ())
61+
func imageOfSize(size:CGSize, _ opaque:Bool = false, @noescape _ closure:() -> ())
6262
-> UIImage {
6363
UIGraphicsBeginImageContextWithOptions(size, opaque, 0)
6464
closure()
@@ -106,7 +106,7 @@ extension Array {
106106
}
107107
}
108108

109-
func lend<T where T:NSObject> (closure:(T)->()) -> T {
109+
func lend<T where T:NSObject> (@noescape closure:(T)->()) -> T {
110110
let orig = T()
111111
closure(orig)
112112
return orig
@@ -144,6 +144,14 @@ class ViewController: UIViewController {
144144
CGContextFillPath(con)
145145
}
146146

147+
let _ = imageOfSize(CGSizeMake(100,100), true) {
148+
let con = UIGraphicsGetCurrentContext()!
149+
CGContextAddEllipseInRect(con, CGRectMake(0,0,100,100))
150+
CGContextSetFillColorWithColor(con, UIColor.blueColor().CGColor)
151+
CGContextFillPath(con)
152+
}
153+
154+
147155
let opts = UIViewAnimationOptions.Autoreverse
148156
let xorig = self.v.center.x
149157
UIView.animateWithTimes(3, duration:1, delay:0, options:opts, animations:{

0 commit comments

Comments
 (0)