Menu Bar Apps

Monday, June 12th, 2017

Menu bar apps refer to apps that sit on the menu bar (a.k.a. status bar) of macOS. It provide instant access of the key functionalities, as well as being accessible all time during a login session.


Providing Services on macOS

Sunday, June 11th, 2017

Apps providing services allows their users to use some of the features while using other apps. For example, you can let the users to launch your app by pressing a short cut key (say ⇧⌘E) while highlighting some text in Safari.


Using Javascript with WKWebView

Saturday, June 10th, 2017

WebKit allows us to use javascript along side with the native swift code. On one hand, we could call the javascript statements in swift. On the other hand, javascript from web view could be able to trigger a delegate method defined in swift code. This gives us a two way communication between the native swift […]


Adding Login Items for macOS

Friday, June 9th, 2017

To create an app that can be auto launched after login (i.e. adding login item) is far more complicated then expected… For sandboxed app, the recommended approach is using the Service Management Framework. (Adding login items using a Shared File List is another approach for non-sandboxed app, which will not be discussed here.) The basic […]


Xcode Keyboard Shortcuts

Thursday, July 7th, 2016

You can find lots of keyboard shortcuts on the web, here just listed some most commonly used ones that make your coding more enjoyable 😊


Using SQLite with Swift

Wednesday, May 4th, 2016

Sometimes it just over-kill to use Core Data for some simple database operations, especially when the data is stored in the app bundle, and data retrieval is the only thing you need. Apple doesn't provide high level API for SQLite in Cocoa / Cocoa Touch framework as of iOS9. It only provides a C library. […]


Using Vector Graphics

Friday, April 8th, 2016

Preparing UI graphics for various devices could be a tedious job with normal, @2x, @3x resolutions… Using vector graphics reduced the hassle of this. Here is how: Prepare the vector graphic in PDF format with 1x resolution Create a new image set in Assets.xcassets, and select "Single Vector" in Scale Factors Drag the PDF file […]


Video File Size of iOS9

Wednesday, April 6th, 2016

Prior to iOS9, the file size of video stored in the Photos library can be easily retrieved by ALAssetsLibrary. However, ALAssetsLibrary has been deprecated in iOS9 and using Photos framework is a bit tricky to do so. Here's how. Implement UIImagePickerControllerDelegate method to get the info of the media file that the user selected. Get […]


Popover for iOS

Wednesday, April 6th, 2016

To present a popover, the simplest way is to present a view controller in storyboard by using segue, and setting the "Kind" option to "Present As Popover".  Popover in Compact Size Class (iPhone) The default behaviour of popover is that it will present modally when the horizontal size class is compact, so it will […]