Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
686 views
in Technique[技术] by (71.8m points)

objective c - Fetched Properties v Relationships (Core Data - iPhone)

I'm a new iPhone developer (of about 4 months or so) who is starting to look at Core Data.

In the "Beginning iPhone 3 Development" book by Dave Mark it mentions that the main difference between fetched properties and relationships is that fetched properties allow lazy loading. However, I have seen other resources and accepted answers on this site which suggest that relationships do allow lazy loading.

For example, if I have a Department object with a to-many relationship with Employee then I would not want a fetch on a given Department to load all the associated employees into memory.

I would be extremely grateful for an authoritative answer on this point, and on the other differences, as it has obvious implications on any design.

Also, I would be extremely grateful if someone could point me towards a reasonable Core Data resource that is a clear and beginner friendly guide (I have been a Java Developer previously but I am new to the iPhone-Way...

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

From the "Core Data Programming Guide", fetched properties represent "weak, one-way relationships". They simply allow you to define the value of a property with a fetch predicate rather than modeling it directly like a relationship.

One major difference is that fetched properties are not live or dynamic like direct relationships. You must explicitly keep fetched properties up-to-date by manually refreshing the object containing the fetched property when changes occur in your object graph that will affect the value of the fetched property.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...