Skip to content

Commit 55bc811

Browse files
committed
let's use a better way of forming a URL
1 parent d62e27e commit 55bc811

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

bk2ch13p631todayExtension/CoffeeTimeTodayExtension/TodayViewController.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ class TodayViewController: UIViewController, NCWidgetProviding {
2828
@IBAction func doButton(sender: AnyObject) {
2929
NSLog("doButton")
3030
let v = sender as! UIView
31-
let t = v.tag // tag is number of minutes
32-
if let url = NSURL(string:"coffeetime://\(t)") {
31+
let comp = NSURLComponents()
32+
comp.scheme = "coffeetime"
33+
comp.host = String(v.tag) // tag is number of minutes
34+
if let url = comp.URLRelativeToURL(nil) {
3335
NSLog("%@", "\(url)")
3436
self.extensionContext?.openURL(url, completionHandler: nil)
3537
}

0 commit comments

Comments
 (0)