-rw-r--r-- 996B Sep 26, 2016 · 55D7D8F · ~1 min

An Elegant Notification.Name Extension in Swift 3

swift шпаргалки

In the new Swift 3 there is now a different initializer for NSNotification (now simply Notification; the NS prefix was dropped):

struct Config {
    static let ShouldCloseBrowserNotification = "ShouldCloseBrowserNotification"
}

let notification = Notification(
    name: Notification.Name(rawValue: Config.ShouldUpdateDialogNotification),
    object: nil,
    userInfo: nil
)
NotificationCenter.default.post(notification)

The name parameter does not look very nice now. But you can extend Notification.Name to make it look better:

extension Notification.Name {
    static let shouldCloseBrowserNotification = Notification.Name("ShouldCloseBrowserNotification")
}

let notification = Notification(
    name: .ShouldUpdateDialogNotification,
    object: nil,
    userInfo: nil
)
NotificationCenter.default.post(notification)

UIKit itself is structured in roughly the same way:

UIKit code

[↵] open page elegantnyj-extension-dlya-notification-name-v-swift-3.md
-rw-r--r-- 1.3K Sep 25, 2016 · 987C1A8 · ~1 min

About the Mac App Store

appmetric mac app store приложения

I had read mentions before that the Mac App Store is dead. About a month ago I hacked together my informer for Yandex AppMetrica and uploaded it to MAS. I started watching the charts (not for long, admittedly). In fact, there were 2 purchases at launch (I even know who both were from). The result surprised me.

Mac App Store home page

Immediately first place in the Business category in the Russian Mac App Store. Of course, it is nice when your icon decorates the list of categories.

Mac App Store categories

Still, just 2 purchases say that people really buy and download very few apps in the Mac App Store. Maybe free ones get downloaded more, but paid ones definitely do not. At least in Russia. It is nothing like the App Store for iOS apps. On top of that, the app reached 8th place in the store's overall top chart.

Mac App Store top chart

So it is not about the category. In other countries, apps are probably bought more often, but in Russia it is very little. Then again, piracy is much more widespread on macOS than on iOS, because there is no jailbreak hassle involved. That is probably why people here do not buy very often.

[↵] open page pro-mac-app-store.md
-rw-r--r-- 452B Aug 28, 2016 · FD72C26 · ~1 min

AppMetric for macOS

appmetric appmetrica macos приложения

Over a couple of evenings I made a simple macOS informer that shows app stats from Yandex AppMetrica. It lives as an icon in the status bar:

  • Shows a list of all apps from AppMetrica.
  • Displays the number of users, sessions, and crashes for today.
  • Automatically refreshes stats in the background.

Download

[↵] open page appmetric-dlya-macos.md
-rw-r--r-- 712B Aug 18, 2016 · 14091F5 · ~1 min

A Block (Closure) as a Class Property in Swift

swift шпаргалки

An example of using a block (closure) as a class property in Swift.

class ChatViewController: UIViewController {

    private var someClosure: (() -> Void)?
    private var anotherClosure: ((arg: Double) -> Bool)?

    func executeClosures() {
        if self.someClosure != nil {
            self.someClosure()
        }

        if self.anotherClosure != nil {
            let boolResult = self.anotherClosure(arg: 2.0)
        }
    }

    func addSelfClosure(closure: (() -> Void)!) {
        self.someClosure = closure
    }

    func printSomething() {
        self.addSelfClosure() {
            print("closure called")
        }
        self.executeClosures() // prints: closure called
    }

} 
[↵] open page blok-zamykanie--kak-svojstvo-klassa-v-swift.md
-rw-r--r-- 651B Aug 18, 2016 · AC73616 · ~1 min

CompareShots v1.2

compareshots ios приложения

CompareShots version 1.2 has been released.

I released it because one of the users emailed me asking to hide the logo and text after an image is selected, because otherwise, if the image is not full-screen, they stick out from behind it or show through. While I was at it, I decided to level up the app a bit more. At last, my subscription to various new libraries came in handy. Now you can draw on top of images. With different colors and brushes of different sizes. One evening, and this beauty was ready :)

Download

[↵] open page compareshots-v1-2.md
-rw-r--r-- 5.5K Aug 17, 2016 · 512B298 · ~4 min

Thoughts on Assassin's Creed Unity

assassin's creed игры

Assassin's Creed Unity

[↵] open page vpechatleniya-ot-assassin-s-creed-unity.md
makoni@arm1:~/blog$ cd ../page-10/ // ← previous cd ./page-12/ // more posts →