Re: Insert text into NSTextView/NSTextStorage does not work
Re: Insert text into NSTextView/NSTextStorage does not work
- Subject: Re: Insert text into NSTextView/NSTextStorage does not work
- From: John Stiles <email@hidden>
- Date: Sat, 29 Dec 2007 07:27:13 -0800
It sounds like your NSTextView* is actually connected to the scroll
view, not the text view. This is an easy mistake to make in Interface
Builder if you are unfamiliar with hooking up the outlets.
You can bulletproof it like this:
assert([registers isKindOfClass:[NSTextView class]]);
So you assert if the object isn't the kind you expect.
Uli Gabor wrote:
Hi
I am pretty new to cocoa and try to refill a NSTextView interface object with new text, but it just does not want to work...
I dropped the "Text View" (NSScrollView) item out of the "Cocoa"->"Views & Cells" folder onto the application.
I declared
IBOutlet NSTextView* registers;
in my class in XCode, loaded the class into the application builder and connected an object of my class with the NSTextView part of the item I dropped onto the application (from object to item).
This seems right to me (at least it does work :D), but whatever I want to do with "registers" does not work...
As I mentioned before, my aim is to replace the whole text with a new (C-)String/char-construct (char*).
I tried
[[registers textStorage] replaceCharactersInRange:NSMakeRange([[registers textStorage] length], 0) withString:@"Hi. Nur ein Test "];
as a little test. Does not work.
A little bit shorter
[[registers textStorage] replaceCharactersInRange:NSMakeRange(0, 0) withString:@"Hi. Nur ein Test "];
also no effect...
I played around with objects of the type NSAttributedString, creating, trying to use the inherited methods of NSTextStorage from NSAttributedString to insert the NSAttributedString into the TextStorage - does not work.
At the moment, I tried something very simple:
NSTextStorage* store = [registers textStorage];
I inspected it in the debugger and it says "0x0" for the value... well seems wrong to me!
Next line:
NSString* blubb2 = [store string];
This should then return the current content of the textbox as far as I know, actually the variable contains value:"0x0";Summary:"nil"... well, seems incorrect to me too (comprehensible at least - a message to a 0x0 object can not return any appropriate value~).
In the meantime I am really clueless what might be wrong, and I hope someone here might know what I am doing wrong or might have missed? :)
Best regards,
Uli
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden