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 …
Author Archives: mmv
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 = …
Copy one or multiple NSTableView rows, Swift
So here’s a simple yet tricky one: you’ve created your NSTableView but now you would like to allow a user to copy to the clipboard one, or a couple of rows. How do you do it? 1. Implement the function copy (func copy(sender: AnyObject?){}), do not confuse with the method for duplicating an object. 2. Get the …
Continue reading “Copy one or multiple NSTableView rows, Swift”
Easy Core Data CSV Exporter in Swift
A new app I’m working on has a Core Data back end and I wanted to implement a quick way to export all the entities into a CSV file and dump it into the Desktop. Here are the snippets to do it: 1. Make sure you get the NSObjects you want to export (in this case …
Back to coding!
You may have noticed a steep drop in post frequency this last couple of months. The reason is that I just got married and well… I code and write this blog on my spare time and, with planning and all, have not had much of that this last months. Should be back to normal in …
Working with localized numbers – NSNumberFormatter Swift 2
In my case, I’m working on a csv importer and I wanted to get from the system the decimal and thousand delimiters. This is the way I do it, a workaround sure but works great: var thousandDelimiter = NSNumberFormatter.localizedStringFromNumber(NSNumber(double: 1234), numberStyle: NSNumberFormatterStyle.DecimalStyle) thousandDelimiter = thousandDelimiter.substringWithRange(thousandDelimiter.startIndex.advancedBy(1)…thousandDelimiter.startIndex.advancedBy(1)) var commaDelimiter = NSNumberFormatter.localizedStringFromNumber(NSNumber(double: 1.02), numberStyle: NSNumberFormatterStyle.DecimalStyle) commaDelimiter …
Continue reading “Working with localized numbers – NSNumberFormatter Swift 2”
Surviving in the App Store
Great article on the challenges of a small company in the App Store. Must read: http://www.theverge.com/2016/3/2/11140928/app-store-economy-apple-android-pixite-bankruptcy Marc
Using NSValueTransformers (Value Transformer) Swift 2.0
So here’s a tricky one, on my upcoming app I sometimes use View-Based TableViews. Mostly, it works like magic, but sometimes you need to use a Value Transformer in the binding to allow the table to understand how to display something. In this example, I needed to convert a NSNumber to a String (and back!). Here’s …
Continue reading “Using NSValueTransformers (Value Transformer) Swift 2.0”
3 Steps to fetch in Core Data (Swift)
1. Get the managed context: let managedObjectContext = (NSApplication.sharedApplication().delegate as! AppDelegate).managedObjectContext! //Change AppDelegate for the name of the class of your Application Delegate 2. Set a variable to store the data: var contentsOfTransactionFetchRequest = [] 3. Fetch the data you need let fetchRequest = NSFetchRequest(entityName: “Whatever”) …
Working with NSUserDefaults in Swift 2
I was quite pleased to see than in Swift is even easier than in Objective-C. Here is how you do it: Create a variable that can access them: var userDefaults = NSUserDefaults.standardUserDefaults() Add values to dictionary: userDefaults.setObject(“StringText”, forKey: “KeyInDictionary”) Read values from dictionary: let text = userDefaults.objectForKey(“KeyInDictionary”) as! …