View this email in your browser

Hi <<First Name>>,

Here are excerpts from the latest posts from my blog since your last delivery. Enjoy!

Blog Series: TableFlip's NSDocument File Type Issues and Fixes

published on May 14, 2020 04:23 pm
This is an overview of a short series of posts I wrote about TableFlip’s 2020 bug. People were getting a “You don’t have permissions” error, a Sandboxing error, when they worked with .txt files, but not with .md files, even though the app treated them the same. The issue boiled down to a misconfiguration on my side that went by unnoticed until I enabled Sandboxing. I was wrongly defining document types in the app’s Info.plist, and I was reporting supported file types in the NSDocument subclass in a manner that didn’t work out well.
Read in browser »

Define and then Hide a New Document Type

published on May 14, 2020 04:16 pm
All previous installments in this series were written some time during the past 6 weeks or so. I couldn’t spend a lot of consecutive time on eitherthe coding problem or the posts, so it became a pain to keep up with all the details and experiments – I hope I have nevertheless told a somewhat intelligible story so far.
Read in browser »

How to Create a NSSavePanel accessoryView in Swift to Pick File Formats

published on May 14, 2020 11:44 am
NSDocument‘s save panel comes prepared with a file format picker that contains the app’s registered document types. This is a very nice convenience, but when you run into trouble with the default picker, as I did, you wonder if writing your own from scratch would be easier.
Read in browser »

Programmatically Select a NSSavePanel File Format to Fix Empty Selections

published on May 13, 2020 06:58 pm
In my quest to vanquish bugs from TableFlip, we intially observed that file extensions would attempt to change after an external file change. It turnes out that this was my fault because I effectively always passed "net.daringfireball.markdown", even when the document type originally was "public.plain-text". Passing the wrong file type to NSDocument.revert(toContentsOf:ofType:) was causing the issue. Trying to use the optional NSDocument.fileType property first, and then providing a fallback, solved the file extension problem.
Read in browser »

Sorting Out Overlapping File Types

published on May 13, 2020 01:45 pm
In my initial post about this problem, I talked about the observations and how I began to figure out where the permission problem came from. I turned out to be an attempt at changing the file extension from .txt to .md. When the user opens a .txt file in your app, macOS makes sure you only get access to that exact file path by default. You cannot just write willy-nilly anywhere else without the user’s permission. File extension changes are included in this protection.
Read in browser »

Sandboxing and Declaring Related File Types

published on May 12, 2020 10:32 am
When I researched what caused TableFlip to lose permissions to write out files, I learned about “related items” in the Sandbox. A good example from the docs is to open a movie file plus its subtitle captions together. The user would select the movie in an NSOpenPanel. This usually grants access to the movie file directly per Sandboxing restrictions. You can declare the subtitles file to be a related item so that the Sandbox allows you to read both. That’s clever.
Read in browser »

Observations of the Curious Problem of NSDocument-Based App Changing the File Extension

published on May 12, 2020 07:08 am
Users have reported problems with TableFlip saving their files recently. One wrote about it in the Zettelkasten forums, if you want to see the problem in context. To reproduce the problem: when you open foo.txt in TableFlip and a text editor, then change the file in the editor rapidly, TableFlip would show a “You don’t have permissions” error once you tried to save changes from TableFlip later.
Read in browser »

Natural Language Toolkit Word Counter

published on May 10, 2020 11:39 am
Back in January when I drafted this post, I had just discovered Apple’s NaturalLanguage.framework. I still don’t know how powerful it really is, but it’s useful for a very simple task already: Counting words. In English and German, I can get pretty accurate results with a String.split at punctuation marks and whitespace. In French, you will get skewed results because these nices folks decided to put whitespace between quotation marks and quoted text.
Read in browser »


Recent Articles:

Delete the Next Word or the Current Selection in Emacs with the Same Shortcut
Indie Support Weeks: beorg
Indie Support Weeks: Soulver
Getting Rid of kCGImageSourceTypeIdentifierHint Error when Loading NSImage from a File
Now Hiring: Freelance Mac Dev

Have a great rest of your day!
Copyright © 2020 Christian Tietze, All rights reserved.

unsubscribe from this list    update subscription preferences 

Email Marketing Powered by Mailchimp