以下是我的原始数组:
{
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
)
按照原始数组顺序。
如何限制此订单更改?
最佳答案
请试试这个
NSArray *orderedSet = [[NSOrderedSet orderedSetWithArray:[people valueForKey:@"ModuleName"]] array];