I want to print out the Text contents of a NSTextView
using the NSLog
functio开发者_JAVA技巧n 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]
Use [updateSource string]
instead. [updateSource textStorage]
is not an NSString
, but rather an NSTextStorage
.
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)
精彩评论