• 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
contract for mutableArrayValueForKey: ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

contract for mutableArrayValueForKey: ?


  • Subject: contract for mutableArrayValueForKey: ?
  • From: Jim Rankin <email@hidden>
  • Date: Tue, 2 Dec 2003 19:12:48 -0500

What's the contract that mutableArrayValueForKey: expects objects to
implement? I'm getting the following exception:

2003-12-02 18:56:51.698 MarshallingTest[4234] *** Uncaught exception:
<NSInternalInconsistencyException> *** -[NSKeyValueSlowMutableArray
addObject:]: value for key types of object 0x509d80 is nil

when trying to add an object to the result of calling
mutableArrayValueForKeyPath: on an object whose interface includes the
following methods:

-(NSMutableArray *)types;
-(void)setTypes:(NSMutableArray *)value;

Now, types returns nil if setTypes: has not been called yet. But
according to the docs for mutableArrayValueForKey:

"2. Otherwise (no set of mutable array primitive methods is found),
searches the class of the receiver for an accessor method whose name
matches the pattern set<Key>:. If such a method is found, each
NSMutableArray message sent to the collection proxy object results in a
set<Key>: message being sent to the original receiver of
mutableArrayValueForKey:."

So doesn't that mean that the first time I add an object to the result
of mutableArrayValueForKey:, it should call setTypes: with an
NSMutableArray containing the object being added? If not, what does
this mean?

Lastly, what's the best way to work around this behavior, when I'm
calling mutableArrayValueForKey: on objects for which I don't have
access to the source? Do I need to check whether the value for the
key(path) returns nil before calling mutableArrayValueForKey(Path): ?

Thanks,
-jimbo

Excelsior! XML Marshaller for Cocoa
http://www.homepage.mac.com/jimbokun/Excelsior.html
_______________________________________________
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: Re: makeWindowControllers question
  • Next by Date: Re: rounding a float
  • Previous by thread: Re: Connecting lots of fields
  • Next by thread: Notification System Woes
  • Index(es):
    • Date
    • Thread