Xcode 4核心数据:如何使用在数据模型编辑器中创建的提取属性 [英] Xcode 4 Core Data: How to use fetched property created in Data Model editor
问题描述
如何在Xcode 4中实现获取的属性?
How do you implement a fetched property in Xcode 4?
这里是两个实体,一本书和一个页面的示例:
Here is an example of two entities, a book and a page:
我按照这里的指南创建fetched属性,它使用变量$ FETCH_SOURCE引用源实体的值: http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreData/Articles/cdRelationships.html
I followed the guidelines here to create a fetched property that references a value from the source entity using the variable $FETCH_SOURCE: http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreData/Articles/cdRelationships.html
现在,一旦我保存并生成源代码,我得到:
Now, once I have this saved and I generate the source code I get this:
// Book.h
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
@class Pages;
@interface Book : NSManagedObject {
@private
}
@property (nonatomic, retain) NSString * title;
@property (nonatomic, retain) NSNumber * pageCount;
@property (nonatomic, retain) Pages * pages;
@end
和...
// Book.m
#import "Book.h"
#import "Pages.h"
@implementation Book
@dynamic title;
@dynamic pageCount;
@dynamic pages;
@end
获取的属性fetchLastPage在哪里?如何在代码中使用它?
Where is the fetched property 'fetchLastPage'? How can I use it in code?
推荐答案
使用 @dynamic 关键字
// In your header
@property (nonatomic, retain) NSArray *fetchLastPage;
// In your class
@dynamic fetchLastPage;
这篇关于Xcode 4核心数据:如何使用在数据模型编辑器中创建的提取属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!