• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Using bindings with an NSArray of NSStrings ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using bindings with an NSArray of NSStrings ?


  • Subject: Re: Using bindings with an NSArray of NSStrings ?
  • From: Allan Odgaard <email@hidden>
  • Date: Fri, 9 Apr 2004 08:27:13 +0200

On 20. Mar 2004, at 0:26, Bjoern Kriews wrote:

If you also want to support editing of the strings, it would in theory be possible to implement "setValue:" in a NSMutableString category, using setString: (and make the array controllers object class be NSMutableString). But at least when I do so, then it goes into infinite recursion calling NNSString's retain before even reaching my setValue: -- I think this is a bug somewhere, but I'll need to look closer into it...
Sounds familiar. I often run into this when fiddling around with unusal bindings stuff.

It seems that I have gotten closer to the actual problem.

If one creates a dynamic class with one of the toll-free bridged classes as super class (e.g. NSCFString) then sending certain messages to an object of this new class will crash, not all though.

This is more or less what happens if we e.g. have a string like this:
NSMutableString* str = [[NSMutableString alloc] initWithString:@"foo"];

And observes it like this:
[str addObserver:observer forKeyPath:@"string" options:0 context:NULL];

The actual class will be NSCFString, when we add the observer, the system will create a new class with NSCFString as super class (or was it the super of this!?!) and switch the isa pointer of our object to this new class.

The next time we send a message to 'str', the program will crash -- although as said, not all messages trigger the problem, but e.g. retain, release and setString: will. Initially I thought it was methods which needed to access and/or mutate instance variables, and somehow this got messed up, because the NSCF... classes are fake in some way or another, but this theory does not seem to hold.



I am posting the information here, hoping that it may help others locate problems easier, since the problem would seem to be quite serious (and several of my reported bugs do seem to be strongly related to this).






** Cocoa FAQ: <http://www.alastairs-place.net/cocoa/faq.txt> **
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Prev by Date: [ANN] AppKiDo 0.902
  • Next by Date: stumped: how do I take action when a text field is tabbed out of?
  • Previous by thread: Re: [ANN] AppKiDo 0.902
  • Next by thread: stumped: how do I take action when a text field is tabbed out of?
  • Index(es):
    • Date
    • Thread