Skip to content

Commit

Permalink
Merge pull request #7 from nolaneo/en/1124-fix-crasher
Browse files Browse the repository at this point in the history
Fix crasher
  • Loading branch information
nolaneo committed Nov 24, 2015
2 parents 463620c + c7a50be commit 8358978
Show file tree
Hide file tree
Showing 15 changed files with 39 additions and 136 deletions.
Binary file added Builds/SeaEye v0.4.zip
Binary file not shown.
4 changes: 0 additions & 4 deletions SeaEye.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
60C73C1819FD7EE10067CDCA /* SeaEyeSettingsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60C73C1719FD7EE10067CDCA /* SeaEyeSettingsController.swift */; };
60C73C1B19FD806A0067CDCA /* back.png in Resources */ = {isa = PBXBuildFile; fileRef = 60C73C1919FD806A0067CDCA /* back.png */; };
60C73C1C19FD806A0067CDCA /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 60C73C1A19FD806A0067CDCA /* [email protected] */; };
60C73C1E19FD8C8A0067CDCA /* WindowExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60C73C1D19FD8C8A0067CDCA /* WindowExtension.swift */; };
60F0232C1A1A95930067C0A0 /* SeaEyeUpdatesController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60F0232B1A1A95930067C0A0 /* SeaEyeUpdatesController.swift */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -148,7 +147,6 @@
60C73C1719FD7EE10067CDCA /* SeaEyeSettingsController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SeaEyeSettingsController.swift; sourceTree = "<group>"; };
60C73C1919FD806A0067CDCA /* back.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = back.png; sourceTree = "<group>"; };
60C73C1A19FD806A0067CDCA /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
60C73C1D19FD8C8A0067CDCA /* WindowExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WindowExtension.swift; sourceTree = "<group>"; };
60F0232B1A1A95930067C0A0 /* SeaEyeUpdatesController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SeaEyeUpdatesController.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -248,7 +246,6 @@
60C73BDE19FC025A0067CDCA /* AppDelegate.swift */,
60C73BE219FC025A0067CDCA /* Images.xcassets */,
60C73BDC19FC025A0067CDCA /* Supporting Files */,
60C73C1D19FD8C8A0067CDCA /* WindowExtension.swift */,
);
path = SeaEye;
sourceTree = "<group>";
Expand Down Expand Up @@ -486,7 +483,6 @@
60C73C1519FD7ECB0067CDCA /* SeaEyeBuildsController.swift in Sources */,
60C73C0619FC16FE0067CDCA /* SeaEyePopoverController.swift in Sources */,
60C73C1819FD7EE10067CDCA /* SeaEyeSettingsController.swift in Sources */,
60C73C1E19FD8C8A0067CDCA /* WindowExtension.swift in Sources */,
603314A819FEBDEA0073EAED /* Build.swift in Sources */,
60F0232C1A1A95930067C0A0 /* SeaEyeUpdatesController.swift in Sources */,
603314A619FDCBFD0073EAED /* CircleCIModel.swift in Sources */,
Expand Down
Binary file not shown.
4 changes: 2 additions & 2 deletions SeaEye/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
if loginItemsRef != nil {
let loginItems: NSArray = LSSharedFileListCopySnapshot(loginItemsRef, nil).takeRetainedValue() as NSArray
println("There are \(loginItems.count) login items")
let lastItemRef: LSSharedFileListItemRef = loginItems.lastObject as LSSharedFileListItemRef
let lastItemRef: LSSharedFileListItemRef = loginItems.lastObject as! LSSharedFileListItemRef
for var i = 0; i < loginItems.count; ++i {
let currentItemRef: LSSharedFileListItemRef = loginItems.objectAtIndex(i) as LSSharedFileListItemRef
let currentItemRef: LSSharedFileListItemRef = loginItems.objectAtIndex(i) as! LSSharedFileListItemRef
if LSSharedFileListItemResolve(currentItemRef, 0, itemUrl, nil) == noErr {
if let urlRef: NSURL = itemUrl.memory?.takeRetainedValue() {
println("URL Ref: \(urlRef.lastPathComponent)")
Expand Down
2 changes: 1 addition & 1 deletion SeaEye/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.3</string>
<string>0.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
15 changes: 0 additions & 15 deletions SeaEye/WindowExtension.swift

This file was deleted.

22 changes: 5 additions & 17 deletions SeaEye/controllers/SeaEyeBuildsController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,6 @@ class SeaEyeBuildsController: NSViewController, NSTableViewDelegate, NSTableView

override init?(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
//Mavericks Workaround
let appDelegate = NSApplication.sharedApplication().delegate as AppDelegate
if appDelegate.OS_IS_MAVERICKS_OR_LESS() {
for (view) in (self.view.subviews) {
if let id = view.identifier? {
println("Setup: \(id)")
switch id {
case "FallbackView": fallbackView = view as NSTextField
case "BuildsTable": buildsTable = view as NSTableView
default: println("Unknown View \(id)")
}
}
}
}
}

required init?(coder: NSCoder) {
Expand Down Expand Up @@ -109,10 +95,12 @@ class SeaEyeBuildsController: NSViewController, NSTableViewDelegate, NSTableView
}
}

func tableView(tableView: NSTableView, objectValueForTableColumn tableColumn: NSTableColumn?, row: Int) -> AnyObject? {
return model.allBuilds[row]
func tableView(tableView: NSTableView, viewForTableColumn tableColumn: NSTableColumn?, row: Int) -> NSView? {
var cellView: BuildView = tableView.makeViewWithIdentifier(tableColumn!.identifier, owner: self) as! BuildView
cellView.setupForBuild(model.allBuilds[row])
return cellView;
}

func selectionShouldChangeInTableView(tableView: NSTableView) -> Bool {
return false
}
Expand Down
27 changes: 7 additions & 20 deletions SeaEye/controllers/SeaEyeIconController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,6 @@ class SeaEyeIconController: NSViewController {

override init?(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
//Mavericks Workaround
let appDelegate = NSApplication.sharedApplication().delegate as AppDelegate
if appDelegate.OS_IS_MAVERICKS_OR_LESS() {
for (view) in (self.view.subviews) {
if let id = view.identifier? {
switch id {
case "IconButton": iconButton = view as NSButton
default: println("Unknown View")
}
}
}
setup()
}
}

required init?(coder: NSCoder) {
Expand Down Expand Up @@ -98,8 +85,8 @@ class SeaEyeIconController: NSViewController {
iconButton.image = NSImage(named: "circleci-success")
}
if NSUserDefaults.standardUserDefaults().boolForKey("SeaEyeNotify") {
let build = notification.userInfo!["build"] as Build!
let count = notification.userInfo!["count"] as Int!
let build = notification.userInfo!["build"] as! Build
let count = notification.userInfo!["count"] as! Int
showSuccessfulBuildNotification(build, count: count)
}
}
Expand All @@ -114,8 +101,8 @@ class SeaEyeIconController: NSViewController {
}

if NSUserDefaults.standardUserDefaults().boolForKey("SeaEyeNotify") {
let build = notification.userInfo!["build"] as Build!
let count = notification.userInfo!["count"] as Int!
let build = notification.userInfo!["build"] as! Build
let count = notification.userInfo!["count"] as! Int
showFailedBuildNotification(build, count: count)
}
}
Expand Down Expand Up @@ -193,14 +180,14 @@ class SeaEyeIconController: NSViewController {
} else {
alternateImageName = imageName.stringByAppendingString("-alt")
}
iconButton.image = NSImage(named: alternateImageName)
iconButton.image = NSImage(named: alternateImageName as String)
}
}

override func prepareForSegue(segue: NSStoryboardSegue, sender: AnyObject?) {
if segue.identifier! == "SeaEyeOpenPopoverSegue" {
self.setupMenuBarIcon()
let popoverController = segue.destinationController as SeaEyePopoverController
let popoverController = segue.destinationController as! SeaEyePopoverController
popoverController.model = self.model
popoverController.applicationStatus = self.applicationStatus
}
Expand All @@ -213,7 +200,7 @@ class SeaEyeIconController: NSViewController {
popoverController.applicationStatus = self.applicationStatus
let view = popoverController.view

let appDelegate = NSApplication.sharedApplication().delegate as AppDelegate
let appDelegate = NSApplication.sharedApplication().delegate as! AppDelegate
if appDelegate.OS_IS_MAVERICKS_OR_LESS() {
popoverController.setup()
}
Expand Down
29 changes: 5 additions & 24 deletions SeaEye/controllers/SeaEyePopoverController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,10 @@ class SeaEyePopoverController: NSViewController {
var model : CircleCIModel!
var applicationStatus : SeaEyeStatus!

let appDelegate = NSApplication.sharedApplication().delegate as AppDelegate
let appDelegate = NSApplication.sharedApplication().delegate as! AppDelegate

override init?(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
//Mavericks Workaround
if appDelegate.OS_IS_MAVERICKS_OR_LESS() {
for (view) in (self.view.subviews) {
if let id = view.identifier? {
println("Setup: \(id)")
switch id {
case "SubcontrollerView": subcontrollerView = view as NSView
case "OpenSettingsButton": openSettingsButton = view as NSButton
case "OpenUpdatesButton": openUpdatesButton = view as NSButton
case "OpenBuildsButton": openBuildsButton = view as NSButton
case "ShutdownButton": shutdownButton = view as NSButton
case "OpacityFixView": opacityFixView = view as NSImageView
default: println("Unknown View \(id)")
}
}
}
opacityFixView.hidden = true
}

}

required init?(coder: NSCoder) {
Expand Down Expand Up @@ -89,9 +70,9 @@ class SeaEyePopoverController: NSViewController {
private func setupStoryboardControllers() {

let storyboard = NSStoryboard(name: "Main", bundle: nil);
settingsViewController = storyboard?.instantiateControllerWithIdentifier("SeaEyeSettingsController") as SeaEyeSettingsController
buildsViewController = storyboard?.instantiateControllerWithIdentifier("SeaEyeBuildsController") as SeaEyeBuildsController
updatesViewController = storyboard?.instantiateControllerWithIdentifier("SeaEyeUpdatesController") as SeaEyeUpdatesController
settingsViewController = storyboard?.instantiateControllerWithIdentifier("SeaEyeSettingsController") as! SeaEyeSettingsController
buildsViewController = storyboard?.instantiateControllerWithIdentifier("SeaEyeBuildsController") as! SeaEyeBuildsController
updatesViewController = storyboard?.instantiateControllerWithIdentifier("SeaEyeUpdatesController") as! SeaEyeUpdatesController
}

private func setupNibControllers() {
Expand Down Expand Up @@ -148,7 +129,7 @@ class SeaEyePopoverController: NSViewController {
private func showUpdateButtonIfAppropriate() {
if applicationStatus.hasUpdate {
let versionString = NSMutableAttributedString(string: applicationStatus.latestVersion)
let range = NSMakeRange(0, countElements(applicationStatus.latestVersion))
let range = NSMakeRange(0, count(applicationStatus.latestVersion))
versionString.addAttribute(
NSForegroundColorAttributeName,
value: NSColor.redColor(),
Expand Down
26 changes: 2 additions & 24 deletions SeaEye/controllers/SeaEyeSettingsController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,10 @@ class SeaEyeSettingsController: NSViewController {

@IBOutlet weak var versionString : NSTextField!

let appDelegate = NSApplication.sharedApplication().delegate as AppDelegate!
let appDelegate = NSApplication.sharedApplication().delegate as! AppDelegate

override init?(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
//Mavericks Workaround
if appDelegate.OS_IS_MAVERICKS_OR_LESS() {
for (view) in (self.view.subviews) {
if let id = view.identifier? {
println("Setup: \(id)")
switch id {
case "RunOnStartup": runOnStartup = view as NSButton
case "ShowNotifications": showNotifications = view as NSButton
case "ApiKeyField": apiKeyField = view as NSTextField
case "OrganizationField": organizationField = view as NSTextField
case "ProjectsField": projectsField = view as NSTextField
case "UsersField": usersField = view as NSTextField
case "BranchesField": branchesField = view as NSTextField
case "VersionString": versionString = view as NSTextField
default: println("Unknown View \(id)")
}
}
setupVersionNumber()
setupInputFields()
}
}

}

required init?(coder: NSCoder) {
Expand Down Expand Up @@ -132,7 +110,7 @@ class SeaEyeSettingsController: NSViewController {

private func setupVersionNumber() {
if let info = NSBundle.mainBundle().infoDictionary as NSDictionary! {
if let version = info.objectForKey("CFBundleShortVersionString") as String! {
if let version = info.objectForKey("CFBundleShortVersionString") as? String {
versionString.stringValue = "Version \(version)"
}
}
Expand Down
14 changes: 0 additions & 14 deletions SeaEye/controllers/SeaEyeUpdatesController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,6 @@ class SeaEyeUpdatesController: NSViewController {

override init?(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
//Mavericks Workaround
let appDelegate = NSApplication.sharedApplication().delegate as AppDelegate
if appDelegate.OS_IS_MAVERICKS_OR_LESS() {
for (view) in (self.view.subviews) {
if let id = view.identifier? {
println("Setup: \(id)")
switch id {
case "VersionLabel": versionLabel = view as NSTextField
case "Changes": changes = view as NSTextField
default: println("Unknown View \(id)")
}
}
}
}
}

required init?(coder: NSCoder) {
Expand Down
8 changes: 4 additions & 4 deletions SeaEye/models/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ class Project: NSObject, NSURLConnectionDelegate {
autoreleasepool {
let receivedData = NSString(data: self.data, encoding: NSUTF8StringEncoding)

if self.validateReceivedData(receivedData) {
if self.validateReceivedData(receivedData as String!) {
var err: NSError?
var json = NSJSONSerialization.JSONObjectWithData(
self.data,
options: NSJSONReadingOptions.MutableContainers,
error: &err
) as Array<NSDictionary>
) as! Array<NSDictionary>

if let error = err {
println("An error occured while parsing the json for project \(self.projectName)")
Expand All @@ -89,7 +89,7 @@ class Project: NSObject, NSURLConnectionDelegate {
}
}

private func validateReceivedData(receivedData: String?) -> Bool {
private func validateReceivedData(receivedData: String!) -> Bool {
if let unwrappedData = receivedData {
//Circle error messages are returned as a JSON object.
//If we are expecting an array then we need to handle this case here before parse.
Expand Down Expand Up @@ -198,7 +198,7 @@ class Project: NSObject, NSURLConnectionDelegate {
if regex == nil {
return true
}
let matches = regex.matchesInString(string, options: nil, range: NSMakeRange(0, countElements(string)))
let matches = regex.matchesInString(string, options: nil, range: NSMakeRange(0, count(string)))
return matches.count != 0
}

Expand Down
10 changes: 5 additions & 5 deletions SeaEye/models/SeaEyeStatus.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ class SeaEyeStatus: NSObject, NSURLConnectionDelegate {
self.data,
options: NSJSONReadingOptions.MutableContainers,
error: &err
) as NSDictionary
) as! NSDictionary

if let error = err {
println("An error occured while parsing the project status from GitHub")
} else {
let latestVersionString = json.objectForKey("latest_version") as String!
let downloadURLString = json.objectForKey("download_url") as String!
let latestVersionString = json.objectForKey("latest_version") as! String
let downloadURLString = json.objectForKey("download_url") as! String
updateURL = NSURL(string: downloadURLString)
changes = json.objectForKey("changes") as String!
changes = json.objectForKey("changes") as! String
println("The latest version of SeaEye is: \(latestVersionString)")
println("Changes\n\(changes)")
if let info = NSBundle.mainBundle().infoDictionary as NSDictionary! {
if let currentVersionString = info.objectForKey("CFBundleShortVersionString") as String! {
if let currentVersionString = info.objectForKey("CFBundleShortVersionString") as? String {
let numberFormatter = NSNumberFormatter()
let currentVersionFloat = numberFormatter.numberFromString(currentVersionString)?.floatValue
let latestVersionFloat = numberFormatter.numberFromString(latestVersionString)?.floatValue
Expand Down
4 changes: 2 additions & 2 deletions SeaEye/views/BuildView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class BuildView: NSTableCellView {
@IBOutlet var openURLButton : NSButton!
var url : NSURL!

func setObjectValue(value: AnyObject) {
func setupForBuild(value: AnyObject) {
if let build = value as? Build {
url = build.url
statusAndSubject.stringValue = build.status.capitalizedString + ": " + build.subject
Expand Down Expand Up @@ -50,7 +50,7 @@ class BuildView: NSTableCellView {
private func setColors(color: NSColor) {
statusAndSubject.textColor = color
statusColorBox.fillColor = color
let cell = statusAndSubject.cell() as NSCell!
let cell = statusAndSubject.cell() as! NSCell
}

private func greenColor() -> NSColor {
Expand Down
Loading

0 comments on commit 8358978

Please sign in to comment.