tags:

views:

80

answers:

1

I have a call, within an NSTextView subclass, that looks like this:

[[self textStorage] replaceCharactersInRange:fullRange withAttributedString:sa];

This call used to work fine and now (after Snow Leopard installation) generates a short message in the console: "Oops". It doesn't crash, it just generates this message and then fails to set the text correctly. The "Oops" message is coming from Apple code, not mine, which is absolutely infuriating.

Can anybody tell me what is going on? Why would the textStorage of an NSTextView EVER generate this message?

I don't know whether it is relevant that when the Oops message is generated, fullRange is equal to (0,0).

...LATER...

Well, I've managed to fix this. This is going to sound crazy. It turns out that the NSTextView I was working with was added to an NSStatusItem as part of an awakeFromNib routine. For whatever reason, Snow Leopard refuses to display the status item until awakeFromNib returns.

When I moved the code for display of the status item into applicationDidFinishLaunching, the problem went away.

I'm crazy, you say? I know, this sounds silly, but try it yourself using sleep(). Prep a statusItem and then sleep() in your awakeFromNib routine. The statusItem won't appear until sleep is over and awakeFromNib returns.

+1  A: 

Please file a bug via http://bugreport.apple.com (and append the bug number here).

I could see how Foundation might cause that to happen. That your range is (0,0) seems a bit odd. Are you trying to insert a string at the beginning of the text storage? If so, use -insertAttributedString:atIndex: instead.

If that fixes the Oops, please do still file a bug. The Foundation should definitely be more helpful than "Oops"!

bbum
Yes, I agree it is odd that my range is (0,0)--but I tried insertAttributeString:atIndex: and still got the same result: "Oops"I will file a bug shortly.
Dennis