• 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
Curious about copyWithZone message from NSArrayController in "GC required" project
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Curious about copyWithZone message from NSArrayController in "GC required" project


  • Subject: Curious about copyWithZone message from NSArrayController in "GC required" project
  • From: Luke Evans <email@hidden>
  • Date: Sat, 12 Jan 2008 20:03:47 -0800

Hi all,

I have a "gc required" project with some entities in a CoreData model, each with requisite subclasses of NSManagedObject.
In particular, I have an entity/class 'A' that declares a property returning an NSArray (which actually returns an ordered list of entity/ class 'B' that is defined as a to-many relationship on the entity A).
Now, in my UI, I have a couple of NSArrayControllers. One of these obtains the 'A's from the managed object context, and provides instances to UI that in turn uses an NSArrayController bound to the property of 'A', such that all the 'B's of a given 'A' are returned in the correct order.


Now, all this is now working correctly (as far as I can tell), but before I got it to work as expected, I had to fix a problem logged in the console as:
*** -[B copyWithZone:]: unrecognized selector sent to instance 0x127f310


The obvious fix of implementing a 'dumb' copyWithZone in the B class (that returns B's 'self' ) got past the problem, but it raises a number of questions in my Cocoa n00b's mind:
1. Why am I being asked to create a copy of B instances anyway? I would have thought that NSArrayController could work quite happily with a reference to my original B's - at least in the GC context. Indeed, forcing this to happen with a trivial implementation of copyWithZone seems to work happily.
2. Is this something I could change through a configuration in my code? I had a property declaration array of B's returnable from A (readonly), and I have tried both retain and assign to see if this would affect anything (it didn't).
3. In general, am I _supposed_ to support the NSCopying protocol on my classes (even knowing that they will only ever be using in GC) as a matter of course. I can certainly think of scenarios where one might like to clone/deepCopy object trees, but had not (yet) read anything in the docs that suggests a requirement to do this as a matter of course in order to use collections and collection controllers. I have been using instances of these classes in all sorts of collections up to now, with no hint of having to implement copyWithZone.


-- Lwe



_______________________________________________

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


  • Follow-Ups:
    • Re: Curious about copyWithZone message from NSArrayController in "GC required" project
      • From: Bill Bumgarner <email@hidden>
  • Prev by Date: Re: Starting my application at user login
  • Next by Date: Re: Release compile failure
  • Previous by thread: Re: Using NSWindow in a dynamically loaded binary / memory issues
  • Next by thread: Re: Curious about copyWithZone message from NSArrayController in "GC required" project
  • Index(es):
    • Date
    • Thread