NSWindow min and max size (Swift 4)

You can force the views to keep a inferred min and max width/height by using AutoLayout, but what if you’re working with several views simultaneously? Wouldn’t it be simpler to have a window min and max width/height?  Just add the following in your NSWindowController: override func windowDidLoad() {         super.windowDidLoad()     …

Open links in the Background

Here’s a quick tip on how to open a URL in the background or foreground depending on a user-set preference.  if(openInBackgroundPreferenceSet == true){                  NSWorkspace.shared.open([linkToOpen], withAppBundleIdentifier: nil, options: NSWorkspace.LaunchOptions.withoutActivation, additionalEventParamDescriptor: nil, launchIdentifiers: nil) }else{                 NSWorkspace.shared.open(linkToOpen) }   Questions / comments? I’m at @MarcMasVi  …

Get Date Day, Month or Year in Swift 3.0

Just a quick update to show how to get Date Day, Month or Year in Swift 3 //Here I’m creating the calendar instance that we will operate with: let calendar = NSCalendar.init(calendarIdentifier: NSCalendar.Identifier.gregorian)         //Now asking the calendar what month are we in today’s date: let currentMonthInt = (calendar?.component(NSCalendar.Unit.month, from: Date()))!           //Now …

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         …