What did I do wrong? It keeps logging (null) but I keep looking for different ways. I did start out with one 2 lines, I was thinking that it was insufficient data.
Cut out the NSBundle line; the file isn’t in your app’s bundle.
And initWithContentsOfFile: is an incomplete method; you need initWithContentsOfFile:encoding:error: or initWithContentsOfFile:usedEncoding:error:.
But this isn’t really the right place. You might like to subscribe to Apple’s cocoa-dev list or omnigroup’s macosx-dev list, although both are high-volume/low-tolerance.
I’m happy to be corrected; I’d assumed it was a place for what it says, AppleScriptObjC.
You can’t write much, but you can write some, courtesy of Cocoa bindings.
I could be wrong – I thought the OP was after some straight Objective-C advice, and nothing to do with AppleScriptObjC. However, if he is looking at it with AppleScriptObjC in mind, he can’t use Foundation functions like NSHomeDirectory().
I want to set the string value of a multi-line text field to this string, but it apparently can’t read UTF-8. What encoding should I then use? I looked in Apple’s Developer Documentation, but that didn’t say what encoding.
P.S. I want to learn Objective-C so badly, but when I can’t find something in the documentation, I’m stuck. Google barley helps.
The encoding depends on the platform and the application the file was created with.
Above I wrote the alternative encodings. If the file was created on a Mac, try NSMacOSRomanStringEncoding
The file is UTF-8, but I can’t set the string value of a text field to the file’s contents. I made it with TextEdit and saved it when I selected “Unicode (UTF-8).” It’s not MacRoman or NSUnicodeStringEncoding. I tried.
I got it! For some weird reason, all of the Cocoa bindings got destroyed because a character in my header file got deleted, but the buttons still worked. Strange.
Either way, it’s working. But, what is the method of setting the string value of a NSTextView?