Jason


  • Categories

  • Search

Swift & Cocoa: Auto Launch at Login

Posted on 2016-04-14 | In Cocoa

This article is based on this blog. I adjust and implement using Swift. The project could be downloaded here.

Development environment:

  • OS X: 10.11.4
  • XCode: 7.3
  • Swift: 2.2

Enable ‘launch at login’ in Mac App Store

Beside works in sandbox mode, to enable ‘launch at login’ in Mac App Store, should mee this requirement:

2.26 Apps that are set to auto-launch or to have other code automatically run at startup or login without user consent will be rejected.

How to deal with it?
Easy, just add a checkbox in Preferences to let user choose auto launch or not. And, make sure, do NOT enable it by default. Otherwise Apple will reject it (I was ever rejected for this reason).

Read more »

Preferences Window

Posted on 2016-04-13 | In Cocoa

This article introduces how to build preferences window on Mac OS X using Cocoa with Swift. The source code can be downloaded here.

Development environment:

  • OS X: 10.11.4
  • XCode: 7.3
  • Swift: 2.2

After it’s finished, the app looks like:

NSTabViewController

The mainly used class is NSTabViewController.
An NSTabViewController object is a container view controller that manages a tab view interface, which organizes multiple pages of content but displays only one of those pages at a time. Each page of content is managed by a separate child view controller. Navigation between child view controllers is accomplished with the help of an NSTabView object, which the tab view controller manages. When the user selects a new tab, the tab view controller displays the content associated with the associated child view controller, replacing the previous content.

Read more »

Storyboard

Posted on 2016-04-13 | In Cocoa

This article introduces how to build status bar app on Mac OS X using Cocoa with Swift. The source code can be downloaded here.

Development environment:

  • OS X: 10.11.4
  • XCode: 7.3
  • Swift: 2.2

After it’s finished, the app looks like:

Storyboard introduction

With storyboards, you can combine as much (or as little) of your application as you want in one canvas, as well as visualize how the parts relate to each other.
Storyboards are organized by scenes (windows and views), which are connected to each other by segues. Segues describe the scenes’ relationships to one another. Storyboards can be used to describe a window and its popover or sheet – or a complicated graph of nested views, each with its own view controller, which previously would have necessitated programmatic construction.
Storyboards were added to OS X in 10.10 Yosemite and to iOS in version 5.

To create the relationship segue between the window controller and the split view controller, control-drag from the blue Window Controller icon in the border on top of the window controller down to the split view controller. In the pop-up Relationship Segue window that appears, select window content.

Read more »
1234
Jason

Jason

Digital Nomad, Mac Developer

12 posts
2 categories
RSS
GitHub Twitter
Links
  • Toolinbox
© 2011 - 2019 Jason