开发者

impact of core data on existing project iphone

I am starting to have a look at Core Data, as many claiming is the best way to persist data.

I have an already working project with its model and objects, the main purpose of the application is to encapsulate things as attributes (NString,NSObject, Custom Object..ecc) into one main class, give the ability to create many instance of this class then save it to storage, later retrieve and display a table list with all saved instance.

In this case, where my class is already defined (as NSObject extension), what could happen with the introduction of Core Data ? Do I need to rewrite my model ?

For example as a first try I created a model in xcode, then associate my object as entity to it. But some of the attributes that were not using standard such as string, int ...ecc got UNDEFINED as type.

@interface Car {
NSString *name;
WheelsType wtype; <-- undefined
NSDate *buy;
CarColor *color; <-- undefined
}
@end

What does that mean ? Am I able to s开发者_高级运维ave just only String,Int,Boolean...ecc but not my Custom Classes ? If not, what the table structure could be ?

thanks


Custom types in CoreData can be declared transformable, meaning that they'll be transformed to and from instances of NSData. The default value transformer works in many cases, but your classes may require a custom NSValueTransformer.

Edit: Since utilizing CoreData changes how you retrieve your data, it'd be wise to review your model. Read the CoreData documentation and then consider how your objects are accessed and how you can avoid faulting objects and properties that will go unused.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜