Before SwiftUI you would easily add, change or remove menuBarItems from your app Storyboard. With the transition to SwiftUI however, there’s no longer a StoryBoard file to edit… So, what now? After the initial surprise, and having spent a few hours reading documentation… It’s actually a very straightforward three step process: 1. In your @main …
Tag Archives: osx
Simple Animations on macOS (Swift 3)
If you’ve ever coded for iOS you’ll most likely be familiar with the UIView animateWithDuration function. Wouldn’t it be great if there would be an OSX equivalent? Well, there sure is, just type the following: NSAnimationContext.runAnimationGroup({_in //Indicate the duration of the animation …
Are we (NSViewController view) the First Responder?
In some cases a class may want to know if it’s the first responder before triggering an action. For instance if several loaded View Controller classes are listening for the same notification, how can they know which one should trigger the action? Well… they should ask their view. In this case a NSTableView class is …
Continue reading “Are we (NSViewController view) the First Responder?”
Undo functionality in Core Data (Swift 3)
If you’re developing a Core Data based application for Mac, wouldn’t it be great if you could add undo support? Well, turns out that is a couple of lines away. Follow the simple steps: 1. Make sure your managedObjectContext has an undo manager, without it Core Data can’t keep track of the changes: …
Continue reading “Undo functionality in Core Data (Swift 3)”
Testing launch experience for a Mac app
In iOS it’s quite easy, you just delete the app and all of it’s data is removed as well. But how do you do it in OSX? Well, you should remove: ~/Library/Application Support/<YOUR OSX APP BUNDLE NAME>/ for example, by default should be: ~/Library/Application Support/com.yourcompany.yourapp/ And this is it! I suggest you do a Project …
Scheduled notifications in macOS
Notifications are a very useful addition to macOS applications, when done right can help inmensly. Here’s how you create scheduled and immediate notifications. Let’s start with the immediate ones: func triggerNotification() -> Void { let notification = NSUserNotification() notification.title = “titleOfNotification” notification.informativeText = “whateverTextYou WantToAdd” notification.soundName = …