Inserting cells at the top of a UITableView with no scrolling

If you would like your table to be refreshed “ala Twitter”, with new data being added on top, here’s a quick an easy way to do it for iOS:  func updateTableViewAfterAdditionInNewArray(){         //Get new feeds and check if counts are different         let countOfAddedItems = oldArray.count – newArray.count    […]

Improve your ⌘ V efficiency

Want to improve your quality of life in 5 seconds? 1. Go to System Preferences 2. Keyboard 3. Shortcuts -> App Shortcuts 4. Click on add -> All Applications –> add “Paste and Match Style” for keyboard shortcut ⌘V Thank you Ally Marc

Random numbers in Swift

Swift 4.2 has introduced a native random number API in the standard library, making it cross platform.  Int.random(in: 1…1000) // → 691 Double.random(in: 0..<1) // → 0.8741555749903935 UInt32.random(in: 0xD800…0xDFFF) // → 55666 Read more in the great article from Ole Begemann, worth a read.    Marc

Resize NSImage Proportionally (Swift)

I wanted a simple function to resize an image to a desired height, while keeping proportions. Here’s what I came up with (based on Marco implementation): extension NSImage {          func resizedImageTo(sourceImage: NSImage, newSize: NSSize) -> NSImage?{         if sourceImage.isValid == false {             […]

NSImageView Aspect Fill

Setting an image to use AspectFill in iOS is trivial, you can set it by code or directly in storyboard.  But how do you do it in macOS? In Cocoa/App Kit there is no property for that, you may scale it , but there is no option for AspectFill (or AspectFit for that matter). So, […]

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){        [linkToOpen], withAppBundleIdentifier: nil, options: NSWorkspace.LaunchOptions.withoutActivation, additionalEventParamDescriptor: nil, launchIdentifiers: nil) }else{        }   Questions / comments? I’m at @MarcMasVi  […]