Xcode4: Different code generated for custom core data managed objects?

Short answer: Don't use Xcode's code generation. Use mogenerator and enjoy an easier life As for the why, it is hard to say. I have never been a fan of the way that Xcode generates the Core Data subclasses and would not recommend them.

We could guess as to why they did the things they have done but based on other issues with Xcode4 and Core Data I would chalk it up to "not ready" or "not fully tested File a radar if you would like to continue to use Xcode code generator.

One thing I do like about Xcode3's generated code using CoreDataGeneratedAccessors is that it's simple. – pokstad Mar 10 at 1:29 1 +1 You can also modify mogenerator to produce classes as you would like them look. Takes a little Ruby but it can be worth your time.

– TechZen Mar 10 at 14:56 Yes it is easy to read and more important it separates the generated code from your code (two levels of files, one human one machine) that the generated code can be re-generated without damaging your code. It is a better solution. – Marcus S.

Zarra Mar 10 at 19:42 I'm guessing the change of template code is like what happens with the other Xcode templates it generates for you. I swear that the OpenGL ES Application template has been different for every iOS SDK version I've tried it on. Anyway, mogenerator's the way to go.

– Brad Larson Mar 10 at 22:18.

It looks like all Xcode4 has done is make explicit what the @dynanmic directive makes implicit. The generated code looks exactly like that generated by Xcode3 when you asked it to generate accessors for a particular attribute (to the clipboard. ) I'm not sure why they decided to do it that way.

Possibly they thought it would make it easier for people to create custom accessors if they just gave them the full basic accessor. It shouldn't be that hard for someone to shoehorn MOGenerator into Xcode4. Anyone?

Come on guys! Anyone? Bueller?

Sigh, looks like it me.

Monogenerator doesn't plugin with Xcode 4 so you could use a runscript triggering mogenerators commandline util: mogenerator -m Resources/CoreData/XcodeProj. Xcdatamodeld/XcodeProj1. Xcdatamodel --base-class RootManagedObjectClass --template-path Resources/MoGenerator -O Sources/Classes.

I discovered the same problem a month or so ago and posted about it on the Xcode 4 preview forums at apple. There's been no reply. To get mine working I just grabbed the method signatures from the .

M file and created the category in the . H file. Basically hacked the generated code back to how XCode 3 would have done it.

I haven't tried with the new release version of Xcode 4.

I use the old XCode 3 way you described in XCode 4 (latest with iOS4.3) and it works as before and what it generates for me is this: #import @class JiraIssueType; @class JiraPriority; @class Customer; @class JiraComment; @class JiraComponent; @class JiraUser; @class Report; @class Tag; @interface JiraIssue : NSManagedObject { } @property (nonatomic, retain) NSString * jiraId; @property (nonatomic, retain) NSString * summary; @property (nonatomic, retain) NSString * detailedDescription; @property (nonatomic, retain) NSDate * createdDate; @property (nonatomic, retain) NSDate * lastUpdatedDate; @property (nonatomic, retain) NSString * key; @property (nonatomic, retain) Report * report; @property (nonatomic, retain) NSSet* comments; @property (nonatomic, retain) JiraPriority * priority; @property (nonatomic, retain) NSSet* components; @property (nonatomic, retain) JiraIssueType * type; @property (nonatomic, retain) Customer * customer; @property (nonatomic, retain) NSSet* tags; @property (nonatomic, retain) JiraUser * assignedTo; @end @interface JiraIssue (CoreDataGeneratedAccessors) - (void)addCommentsObject:(JiraComment *)value; - (void)removeCommentsObject:(JiraComment *)value; - (void)addComments:(NSSet *)value; - (void)removeComments:(NSSet *)value; - (void)addComponentsObject:(JiraComponent *)value; - (void)removeComponentsObject:(JiraComponent *)value; - (void)addComponents:(NSSet *)value; - (void)removeComponents:(NSSet *)value; - (void)addTagsObject:(Tag *)value; - (void)removeTagsObject:(Tag *)value; - (void)addTags:(NSSet *)value; - (void)removeTags:(NSSet *)value; @end.

Generating those accessors was really handy, not sure why they've changed that. I use this snippets as an alternative: - (void)addsObject:( *)value; - (void)removesObject:( *)value; - (void)adds:(NSSet *)value; - (void)removes:(NSSet *)value.

Short answer: Don't use Xcode's code generation. Use mogenerator and enjoy an easier life. As for the why, it is hard to say.

I have never been a fan of the way that Xcode generates the Core Data subclasses and would not recommend them. We could guess as to why they did the things they have done but based on other issues with Xcode4 and Core Data I would chalk it up to "not ready" or "not fully tested". File a radar if you would like to continue to use Xcode code generator.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions