以下是我原来的数组:
{
FilePath = "Selfcare.jpg";
ModuleId = 18;
ModuleName = "Infant N Toddler";
SkillLevelID = 59;
SkillLevelName = "Self Care";
},
{
FilePath = "Preschool.jpg";
ModuleId = 18;
ModuleName = "Infant N Toddler";
SkillLevelID = 60;
SkillLevelName = "Preschool Readiness";
},
{
FilePath = "Learning_Primary.jpg";
ModuleId = 22;
ModuleName = Cognitive;
SkillLevelID = 71;
SkillLevelName = "Learning Readiness - Primary Skills";
},
{
FilePath = "PreAcad_Primary.jpg";
ModuleId = 22;
ModuleName = Cognitive;
SkillLevelID = 72;
SkillLevelName = "Pre-Academics: Primary Skills";
}
当我应用distinctUnionOfObjects
时NSArray *curriculums = [array valueForKeyPath:@"@distinctUnionOfObjects.ModuleName"];
这改变了给出结果数组的顺序
<__NSArrayI>(
Cognitive,
Infant N Toddler
)
应该给出
<__NSArrayI>(
Infant N Toddler,
Cognitive
)
按照原始数组顺序。
如何限制此订单更改?
答案 0 :(得分:2)
请尝试这个
NSArray *orderedSet = [[NSOrderedSet orderedSetWithArray:[people valueForKey:@"ModuleName"]] array];