Jason


  • Categories

  • Search

Status Bar App

Posted on 2016-04-08 | 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:

How to Run as Status Bar App?

In another word, how to make the application not show a dock icon? The key point is to modify the application’s Info.plist file and indicate that it’s an agent. “Agent” is Apple’s term for a background application that doesn’t present a dock icon.
Select the project at the top of the project navigator. Open the Info tab at the top of the main editor. Add a new entry of Application is agent (UIElement) and set the value of this entry to YES.

Read more »

Use NSOutlineView With NSTreeController

Posted on 2016-04-06 | In Cocoa

This article describes the steps to use NSOutlineView With NSTreeController. The source code can be downloaded here.

Development environment:

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

Steps

Create Basic Project

Refer to commit till #40ccec2.

Add UI Controls

Refer to commit till #2853186.
After done, the UI looks like:

Read more »

Use NSOutlineView With DataSource and Delegate

Posted on 2016-04-06 | In Cocoa

This article describes the steps to use NSOutlineView With NSOutlineViewDataSource and NSOutlineViewDelegate. The source code can be downloaded here.

Development environment:

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

Steps

Create Basic Project

Refer to commit till #fa626ee.

Add Model Class of “Node”

Refer to commit till #e302b91.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class Node: NSObject {
var title = "Node"
var isGroup = false
var children = [Node]()
weak var parent: Node?
override init() {
super.init()
}
init(title: String) {
self.title = title
}
func isLeaf() -> Bool {
return children.isEmpty
}
}

Read more »
1…34
Jason

Jason

Digital Nomad, Mac Developer

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