English 中文(简体)
核心数据集基于定购关系的财产
原标题:Core Data fetches based on properties of ordered relationships
  • 时间:2010-11-26 20:30:24
  •  标签:
  • core-data

我的“Semart”和“Sch”一样:先导功能是按要求建立的。

搜索所使用的实体有朝向关系。 这种关系是出于分类目的在目的地实体中储存的指数。

我的问题是,我想根据既定关系中的最后价值观,制定一项规则,但我无法说明如何建立这样做的前提,因为关系不是一阵。 核心数据没有实际了解这一命令。

我在归还定购物的类别上拥有一只读物,但由于核心数据库没有财产,这似乎无助于申请。

我认为,唯一的选择是将关系中最后一批物品从单独财产中解冻和储存。 这是唯一的解决办法吗?

问题回答

如果我正确理解这个问题,我就这样做了。 请允许我说,“独一无二”有两个实体,“独一无二”是指财产,与拥有(国歌*)财产(国名)财产的密谋关系。

请允许我说,你想要的是与某种扼杀相对应、而且其意向令符合某种条件的独角兽物体,那么你就可以用两种基调和一种像这样的NSFetchRequest。

NSManagedObjectContext *context = [self managedObjectContext];

// Create some top level entities
TopEntity *aTop = [TopEntity insertInManagedObjectContext:context];
aTop.name = @"This is Your Name";
TopEntity *bTop = [TopEntity insertInManagedObjectContext:context];
bTop.name = @"This aint a Name";    
TopEntity *cTop = [TopEntity insertInManagedObjectContext:context];
cTop.name = @"This is My Name";    

// Add some data
NSInteger i, len = 30;
for(i=0; i<len; i++) {
    // Create a new object
    MyEntity *entity = [MyEntity insertInManagedObjectContext:context];
    entity.orderValue = i;
    entity.data = [NSString stringWithFormat:@"This is some data: %d", i];
    if(i < 10) {
        [aTop addObjectsObject:entity];
        [entity addTopObject:aTop];
    } else if (i < 20) {
        [bTop addObjectsObject:entity];
        [entity addTopObject:bTop];            
    } else {
        [cTop addObjectsObject:entity];
        [entity addTopObject:cTop];                        
    }
}

// Save the context
NSError *error = nil;
[context save:&error];

// A predicate to match against the top objects
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"name BEGINSWITH %@", @"This is"];
// A predicate to match against the to-many objects
NSPredicate *secondPredicate = [NSPredicate predicateWithFormat:@"ANY objects.order < %d", 5];
NSFetchRequest *fetch = [[NSFetchRequest alloc] init];
[fetch setEntity:[NSEntityDescription entityForName:@"TopEntity" inManagedObjectContext:context]];
[fetch setPredicate:predicate];
NSArray *result = [[context executeFetchRequest:fetch error:&error] filteredArrayUsingPredicate:secondPredicate];


for(TopEntity *entity in result) {
    NSLog(@"entity name: %@", entity.name);         
}

So, essentially you can just wrap the results of your fetch request with another predicate and use the ANY keyword.

我没有想到这种效率是多么高的,但它为本案工作。 采用上述办法将产生“这是你的名字”,即与第一个顶峰相匹配。

我不认为,只有按点要求,才有办法限制到n

除了按照你提到的关系提及最后的零件外,你还可以尝试一种“甲型”特性,在你理顺清单顺序时(例如,在用户发起的情况下,或者在拖拉和干道重新排序期间)将其lip。

或者,你可以单独提出请购单要求,要求按您的类型钥匙进行分类,并限制(通过——打造FetchLimit: )到<><>>>。

视之为关系或属性有些是“mes”,而单价限制则比较昂贵(由于多次往返旅行)。 如果你通过一次性用户行动重新排列顺序,那么使用关系或归属方法也许会更好,因为工作是摊销的,而不是在一系列 f中一劳永逸地进行。 我已经找到了更好的办法,并将密切注视这一点。





相关问题
iPhone Core Data Recursive Relationships

I m having some trouble with a recursive relationship in core data. I ve got a managed object called a "SearchCategory", and that category can have "Categories" and it can also have a "Category." In ...

Plist Hierarchy and All Option

I have a string of data in a plist, which I ve got to display, hierarchically like this: Menu>Chapter>SubChapter>item>item details This might be super simple, in my initial menu, how would I have ...

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 ...

Cocoa Core Data newbie how-tos

I am one of the great unwashed masses of .NET developers keen to try their hands at Mac OS X development. At the moment I am trying to figure out the various elements of Cocoa and getting a bit stuck ...

中间储存的核心数据

我想将核心数据作为输入数据库服务器更大数据集的切身。

Limit the returned resultset in CoreData

In CoreData, if I want to limit the returned resultset to 100, is it enough to just set the fetch limit to 100, or do I need to set the fetch batch size to 100 as well?

热门标签