While answering this question, which involved writing a plain text string out to file with a non standard extension. In this case .meta but it could be anything.
I noticed that when I used the Applescript code to write the file out.:
set meta_text to "alt " & alt_text & return & "copyright " & copyrightText & return & "signature " & signatureText
set meta_file to open for access meta_path with write permission
write meta_text to meta_file
close access meta_file
The resulting file's text could be seen with Quicklook and TextEdit.app automatically was set as the default app to open it.
I did not think anything of this until I changed the code to use Objective - C. ( Actually ApplescriptOBJC but in all intents and purpose the same thing)
BOOL success = [meta_text writeToFile: meta_file atomically:YES encoding:NSUnicodeStringEncoding error:nil];
And found that the resulting file's text could not be seen with Quicklook and TextEdit.app was not automatically set as the default app to open it.
I realised that actually afaik the latter behaviour was what I should expect from both code executions.
Can anyone explain why there is this difference and how to get the Objective - C code to set the (I assume) UTI so that it also gives the same behaviour as the Applescript code.