<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Thank you all (Ole, Rien, Adrian)!&nbsp;It’s alive!<div class=""><br class=""><div class="">You are right it’s a shame how poorly it is documented at the moment. There are many overloads of «&nbsp;scheduleRepeating()&nbsp;» with different parameters and the headers are not that helpful…</div><div class=""><br class=""></div><div class="">Thanks again.</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">Le 17 oct. 2016 à 00:32, Hooman Mehr &lt;<a href="mailto:hooman@mac.com" class="">hooman@mac.com</a>&gt; a écrit :</div><br class="Apple-interchange-newline"><div class=""><blockquote type="cite" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class=""><br class="Apple-interchange-newline">On Oct 16, 2016, at 11:25 AM, Thierry Passeron via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Hello All,<br class=""><br class="">I’m in the process of migrating older code to Swift 3 and I’m stuck on this one.<br class="">How do you create a timer dispatch source?<br class=""><br class="">Old code:<br class=""><br class="">let source = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue)<br class=""><br class="">dispatch_source_set_timer(source, dispatch_time(DISPATCH_TIME_NOW, 0), UInt64(interval * 1000_000_000), 0)<br class="">dispatch_source_set_event_handler(source) {<br class="">&nbsp;&nbsp;// Do something useful<br class="">}<br class=""><br class="">dispatch_resume(source)<br class=""><br class="">New code:<br class=""></div></div></blockquote><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);">let</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span>timer =<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">DispatchSource</span><span class="" style="font-variant-ligatures: no-common-ligatures;">.makeTimerSource(queue: queue)</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">timer</span><span class="" style="font-variant-ligatures: no-common-ligatures;">.</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(62, 30, 129);">scheduleRepeating</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(wallDeadline: .</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(62, 30, 129);">now</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(), interval: .</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(62, 30, 129);">seconds</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">1</span><span class="" style="font-variant-ligatures: no-common-ligatures;">))</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(62, 30, 129);"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">timer</span><span class="" style="font-variant-ligatures: no-common-ligatures;">.</span><span class="" style="font-variant-ligatures: no-common-ligatures;">setEventHandler</span><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-converted-space">&nbsp;</span>{</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);"><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="font-variant-ligatures: no-common-ligatures;">// Do something useful</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;">}</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(62, 30, 129);"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">timer</span><span class="" style="font-variant-ligatures: no-common-ligatures;">.</span><span class="" style="font-variant-ligatures: no-common-ligatures;">resume</span><span class="" style="font-variant-ligatures: no-common-ligatures;">()</span></div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><br class=""></span></div></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">Isn’t it nice? It is a pity it is not well documented yet.</div><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><blockquote type="cite" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class=""><div class="">Xcode is not helping me with any of the required refactoring. The convert tool throws many errors but no proposition.<br class="">I have tried to explore the New Dispatch headers with no luck. DISPATCH_SOURCE_TYPE_TIMER can’t be found… ok so It seems to be replaced with a protocol DispatchSourceTimer and … no initializer… I think I don’t yet catch with the whole philosophy of this new version.<span class="Apple-converted-space">&nbsp;</span><br class=""><br class="">I’d be pleased if anyone cared to enlighten me.<br class=""><br class="">Thanks and regards,<br class="">Thierry<br class=""><br class="">_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-users" class="">https://lists.swift.org/mailman/listinfo/swift-users</a></div></div></blockquote></div></blockquote></div><br class=""></div></div></body></html>