Thanks. Maybe I'll try that.
On Sep 1, 2011, at 5:10 PM, Quincey Morris wrote: > On Sep 1, 2011, at 13:19 , Andrew Kinnie wrote: > >> I used Xcode 4 to generate the initial subclass, then added other business >> rules methods as needed. I noticed, however, that the to-many relationship >> methods are stubbed in to the .h file, but there is no implementation in the >> .m file and it reports incomplete implementation. However, the methods >> appear to actually work. >> >> So I am confused. Am I supposed to implement these or not? If not, what >> can I do to get rid of the warning? >> >> Is there an explanation as to why the Generate Managed Object Subclass menu >> item would create them in the .h but not implement them in the .m? I ask >> because I am concerned that I am missing something about Core Data. > >> - (void)addMediaObject:(MediaResource *)value; >> - (void)removeMediaObject:(MediaResource *)value; >> - (void)addMedia:(NSSet *)value; >> - (void)removeMedia:(NSSet *)value; > > Core Data provides implementations of those methods, as well as "normal" > setters and getters. You don't have to do that. > > However, you *do* have to construct your custom subclass .h file so that it > advertises these methods to clients of the class, otherwise you get compile > errors wherever they're used. > > For getters and setters, this is easy. You put public @property declarations > in the .h file and put @dynamic statements in the .m file. > > For to-many accessors, it's a bit harder, because there's no direct > equivalent of @property. Traditionally, the way to handle it was to put the > .h declarations inside a dummy category. The compiler and linker don't > complain if methods declared in a category don't exist at link time. In the > past, all of those Xcode menu items that gave you boilerplate code put the > code inside a dummy category. > > As it happens, I haven't needed to update any Core Data apps since Xcode 4.x, > so I don't know if it's now trying to do something cleverer than what I > described in the previous paragraph. My guess is not. Perhaps you took the > accessor declarations out of the dummy category because it seemed to serve no > purpose. Perhaps Xcode now assumes you know to use a dummy category. Whatever > the reason, you should still be able to use the dummy category technique > without difficulty. > > _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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/archive%40mail-archive.com This email sent to arch...@mail-archive.com