This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//: Playground - noun: a place where people can play | |
var num = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15].map { (i) -> String in | |
let fizz = (i % 3) == 0 | |
let buzz = (i % 5) == 0 | |
let fizzBuzz = fizz && buzz | |
let char = String("\(i)") | |
if fizzBuzz { return "FizzBuzz" } else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func collapseToHeight(height:CGFloat) { | |
if attached { | |
return | |
} | |
isCollapsed = true | |
var newFrame = frame | |
newFrame.size.height = height | |
newFrame.origin.y += (frame.height - height) | |
XCGLogger.error(newFrame.origin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension NSFont { | |
func isBold() -> Bool { | |
return NSFontManager.sharedFontManager().traitsOfFont(self).contains(.BoldFontMask) | |
} | |
func isItalic() -> Bool { | |
return NSFontManager.sharedFontManager().traitsOfFont(self).contains(.ItalicFontMask) | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func toggleTaskListOverRange(range:NSRange) { | |
((textView?.textStorage?.string)! as NSString).enumerateSubstringsInRange(range, options:.ByLines) { (line, lineRange, rangeWithTerminators, nil) in | |
if let attributedLine = (self.textView?.textStorage?.attributedSubstringFromRange(rangeWithTerminators)) { | |
if attributedLine.rangeOfCheckedBox().location != NSNotFound { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func toggleTaskListOverRange(range:NSRange) { | |
((textView?.textStorage?.string)! as NSString).enumerateSubstringsInRange(range, options: .ByLines) { (line, lineRange, rangeWithTerminators, nil) in | |
if (self.textView?.textStorage?.attributedSubstringFromRange(lineRange)) != nil { | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var doc:Document? { | |
didSet { | |
if let myDoc = doc { | |
textField?.lineBreakMode = .ByTruncatingMiddle | |
textField?.stringValue = myDoc.note.docID | |
toolTip = myDoc.note.docID | |
let appIcon = AppIconProvider.iconImagefor(myDoc.note.appBundleID) | |
let genericAppIconTiff = NSWorkspace.sharedWorkspace().iconForFileType(NSFileTypeForHFSTypeCode(OSType(kGenericApplicationIcon))).TIFFRepresentation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import Cocoa | |
protocol SplitViewCollapseable: NSSplitViewDelegate { | |
var splitView:CustomSplitView? { get set} | |
var masterListExpandedWidth:CGFloat? { get set} | |
var masterListCollapsedWidth:CGFloat? { get set } | |
func collapseMasterList() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func handleTaskAdded(notif:NSNotification) { | |
tasksTableView?.reloadData() | |
if let tableView = tasksTableView, addedTask = notif.object as? Task { | |
tableView.enumerateAvailableRowViewsUsingBlock({ (rowView, row) in | |
print("enumerated \(row)") | |
if row != 0 { | |
if let cell = rowView.viewAtColumn(0) as? TaskCell { | |
if let cellTask = cell.task?.id { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func tableView(tableView: NSTableView, heightOfRow row: Int) -> CGFloat { | |
if row == 0 { | |
return 36.0 | |
} | |
return 53.0 | |
} | |
func tableView(tableView: NSTableView, didAddRowView rowView: NSTableRowView, forRow row: Int) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func tableViewSelectionDidChange(notification: NSNotification) { | |
let tv = notification.object as! NSTableView | |
let view = tv.viewAtColumn(0, row: tv.selectedRow, makeIfNecessary: false) as? TaskListCell | |
let rowView = view?.superview as? NSTableRowView | |
if rowView?.selected == true { | |
view?.textField?.textColor = NSColor.blueColor() |