Kirill Titov Blog Personal blog of Kirill Titov. en Copyright 1989-2k17 Kirill Titov 2018-12-06T10:16:05+00:00 60 Red Snapper @ Erarta Museum <p>Red perches showed everything to everyone once again.</p> <a class="img" href="" data-orig-img=""><img src="" data-orig-img="" /></a> <p><sub>+88 photographs without commentaries.</sub></p> 2018-06-03T19:33:05+00:00 Red Snapper @ Erarta in Saint-Petersburg announce <p>So apparently I'm gonna be officially shooting photographs of Red Snapper concert this Saturday at Erarta Museum. Concert report will be up on Sunday.</p> <p>As they say — please stand by.</p> <p>Upd: <a href="">done</a>.</p> 2018-06-03T19:50:34+00:00 Hospitality Ukraine 2017 <p>Makoto, Spectrasoul, London Elektricity, Metrik and Dynamite MC including our own stars like Tapolsky, Sunchase and Vera Sue. It's illegal to miss that.</p> <a class="img" href="" data-orig-img=""><img src="" data-orig-img="" /></a> <p><sub>+160 photographs without comments.</sub></p> 2018-05-29T16:49:18+00:00 House <a class="img" href="" data-orig-img=""><img src="" data-orig-img="" /></a> Why DispatchSource.makeTimerSource not working? <p>Say you did the following</p> <p><script src=""></script></p> <p>and proceeded to your business, but the timer fired once or even not a single time. Why? It's because your <code>timer</code> object has been eaten by garbage collector, and when <code>DispatchSourceTimer</code> is deinited, it (obviously) stops itself. It's worth reminding that GC is triggered when scope closes, in our case — after <code>async</code> block fired. Therefore, if you want to regularly run certain task, you should store reference to timer object in a global storage, which would live as long as you want, but not the GC. It's also recommended to wrap access to this storage with synchronous serial queue to avoid shameful race conditions.</p> <p></p> <p>P.S. I might be mistaken, but in Swift 3 the behaviour was different, and timer execution did not stop like that. I'm not sure if it's correct behaviour, but anyway, in Swift 4 it's quite reasonable.</p> 2018-12-06T10:16:05+00:00 Secret of Self in Swift <p>Anyone who study Swift programming language surely knows what keyword <code>self</code> means — it is reference to current object inside class instance context. Completely normal stuff in almost any objective language. The tricky part begins when one deals with static methods and properties as well as with the famous Swift's protocol-oriented paradigm. We won't emphasize attention on protocol philosophy, instead let's proceed to the most interesting part, and I'm quite sure anyone had business with it.</p> <p>I'm talking about calling static method from protocol extension or defining a protocol method which must return eventual type. All of that is a particular case of late static binding, and everybody may google it anytime.</p> <p>It's quite straight and simple in case of commonplace static method inside class or structure — method is easily called with type name, or you just call <code>type(of: self)</code> which returns current type and from that you may call static methods. However when there is no concrete type yet, but only protocol and/or its extensions (i.e. metatype), language simply won't let us do it because protocol cannot contain implementation and protocol extension is not considered as concrete code, hence we get compiler error <code>Static member 'staticMethodName' cannot be used on protocol metatype 'ProtocolName.Protocol'</code>.</p> <p>The solution is using keyword <code>Self</code> (exactly that, capitalized) which is a reference to eventual type conforming to protocol. Official documentation has <a href="">only one mentioning</a> of this keyword:</p> <blockquote>In that [protocol] context, Self refers to the eventual type that conforms to the protocol.</blockquote> <p>Respectively, this keyword works only in metatype context (protocols and protocol extensions), in concrete classes or structures you get error <code>Use of unresolved identifier 'Self'</code>.</p> <p><script src=""></script></p> <p>P.S. All of it relates to Swift versions 3 and 4, and may be changed in future. I'll try to not forget to update this article if anything changes (it might, as we all know).</p> 2018-10-04T15:01:59+00:00 Ultra short stories <p>Once I had hard time trying to sleep and decided to shoot the sunrise at our ponds.</p> <img src="" data-orig-img="" /> <img src="" data-orig-img="" /> <img src="" data-orig-img="" /> Railway dilogy <a class="img" href="" data-orig-img=""><img src="" data-orig-img="" /></a> <a class="img" href="" data-orig-img=""><img src="" data-orig-img="" /></a> Sergeant McPuss <a class="img" href="" data-orig-img=""><img src="" data-orig-img="" /></a> 2017-11-03T12:55:07+00:00 Website update, astonishing! (no) (yes) (no) <p>Now the website has an RSS-feed, one can add it wherever you want (damn you, Google!) and read me whenever you wish (as if you couldn't before, lol).</p> <p>In case your client didn't catch it by passing link to website itself (it should work, though), here is <a href="">direct link</a> to feed.</p> 2017-05-03T11:22:51+00:00