Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Insert text into NSTextView/NSTextStorage does not work



Hi

Yeah... well it was connected the right way, but... I am stupid :D

I tend to have such "tests" working without clicking a button - means, my code was in the init method of the object.
In my euphoria of coding I did not even realized, that my application window is not even open...
Changed the init method to awakeFromNib and now it works :)


I had the same problem with Delphi in school two years ago: The interface item was working seamlessly with every other student, even my teacher did not see what I was doing wrong, and eventually I figured it out by myself~


Thanks anyway,
I already forgot how I got this idea now, but the mail helped ;)



Best regards, 
Uli



-------- Original-Nachricht --------
> Datum: Sat, 29 Dec 2007 07:27:13 -0800
> Von: John Stiles <email@hidden>
> An: Uli Gabor <email@hidden>
> CC: email@hidden
> Betreff: Re: Insert text into NSTextView/NSTextStorage does not work

> 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
> >   

-- 
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! 
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer
_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden

References: 
 >Insert text into NSTextView/NSTextStorage does not work (From: "Uli Gabor" <email@hidden>)
 >Re: Insert text into NSTextView/NSTextStorage does not work (From: John Stiles <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.