Retry! in the wild

In perfect world every action finish with the success. In real world it's not. In perfect world sending network request returns with a result. In real world it fail sometimes due to dozen of reasons, and since we're living in the real world I have to deal with it. don't…

Code at the end of the queue

NSOperation and NSOperationQueue are great and useful Foundation framework tools for asynchronous tasks. One thing puzzled me though: How can I run code after all my queue operations finish? The simple answer is: use dependencies between operations in the queue (unique feature of NSOperation). It's just 5 lines of code…

Swift reflection about food

Reflection in practice Reflection technique may be useful to build quasi generic functions that operate at runtime. It may be quasi type safe, though it uses runtime too - as such can't be optimised/validated during compilation. With Objective-C we used <runtime/objc.h> and do all the…

ChunkSequence 🔪🍰

Have cake and eat it Have a cake and consume the cake by the Swift function, at the same time. Magic. The nature of the Swift type is that it is copied or copied on write. When I assign A to B (A = B), then effectively B is copy of…

Fast pattern search in Swift... since 1974

the fastest known ways to find one string of characters in another Stay with me. At the beginning brief introduction, later on Swift implementation, tests and conclusion. Halt and Catch Fire thing I really enjoy Halt and Catch Fire tv show. Season 1 was about hardware, while season 2 is…

Practical Swift: pages generator - build once, use many

In the real world, at some point, we all have to deal with data that is fetched from a backend service, page by page. It's called paging. Everybody does this! Nothing to be ashamed of ;-) Here is one of the ways in which a Swift pattern (well, not specific…

Let's talk about sections for NSTableView

Today, let's talk about table view in AppKit for OS X. Programming for OS X have a long history behind. History that is not always known to the iOS programmers, however it is the Mother of UIKit. An NSTableView object displays data for a set of related records, with rows…