Frustrating problem with NSTextView
-
27-09-2019 - |
Question
I want to print out the Text contents of a NSTextView
using the NSLog
function in Objective-C. The code I have so far is:
NSString *s=[updateSource textStorage];
NSLog(s);
All I get is the error:
[NSConcreteTextStorage getCharacters:range:]: selector not recognized [self = 0x43f4b0]
Solution
It's not the cause of your problem, but you should be using NSLog(@"%@",s); to log your string. The first argument of NSLog should always be a format string, and not the value you're trying to log.
(if you don't, your app will likely crash if the value contains percent characters)
OTHER TIPS
Use [updateSource string]
instead. [updateSource textStorage]
is not an NSString
, but rather an NSTextStorage
.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow