我的核心數據對象是這樣的:獲取與秩序
Person
-------
presonId
name
現在假設我得到的personsIds
數組,我想獲取所有Person
對象包括本personsIds
陣列。
所以我的讀取請求將是:
NSArray *personsIds = [self getPersonsIds];
// fetch all persons with ids in personsIds
NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"Person"];
request.predicate = [NSPredicate predicateWithFormat:@"presonId in %@", personsIds];
NSArray *results = [self.context executeFetchRequest:request error:&anyError];
現在我的問題是這樣的:
的personsIds
的順序是非常重要的,我想的是,results
陣列將在相同的順序進行排序。
我無法與personId
陣列混亂,無法對其進行排序或什麼..
公告稱,personsIds
陣列可以有更多的對象比results
陣列
這個問題是我的PERSONID陣心不是排序,但它的順序很重要,所以我不能排序。我需要的結果與我的personId數組的結果是一樣的。也許我不應該在這裏使用字排序..不適當更新我的問題 – Eyal
然後,你需要通過循環結果和排序像personIds數組排序自己排序自己。 – Cornelius