Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Core Data: Where to put awakeFromFetch and awakeFromInsert?

I would like to override awakeFromFetch and awakeFromInsert.

As I leave the auto-generated NSManagedObject subclasses unchanged and put my custom code in categories, my question is:

Where do I put awakeFromFetch and awakeFromInsert in order that these methods get called correctly?

like image 479
AlexR Avatar asked Dec 11 '22 21:12

AlexR


1 Answers

If your managed object subclass files are generated by Xcode, then you can also put the methods in a category of the managed object subclass, so that the code is not overwritten when you re-generate the class files in Xcode.

MyEntity+Extensions.h

#import "MyEntity.h"

@interface MyEntity (Extensions)
@end

MyEntity+Extensions.m

#import "MyEntity+Extensions.h"

@implementation MyEntity (Extensions)

- (void)awakeFromFetch
{

} 

- (void)awakeFromInsert
{

}
@end
like image 101
Martin R Avatar answered May 07 '23 05:05

Martin R