开发者

Frustrating problem with NSTextView

开发者 https://www.devze.com 2023-01-27 04:03 出处:网络
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:

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)

0

精彩评论

暂无评论...
验证码 换一张
取 消