1
我有一組核心數據項目,我想根據已設置爲整數16的數字屬性進行排序。它只是一個具有自定義排序的項目列表,我添加了一個'排序'整數,以便我可以說abc-> 1 cba-> 2 aaa-> 3等。我想使用1,2,3排序並顯示鍵(這是另一個屬性)。核心數據使用NSSortDescriptor對數值進行排序
我不知道如何做到這一點,我猜我需要改變選擇器,但我不知道該怎麼做。
request.sortDescriptors = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"ordering" ascending:YES selector:@selector(localizedStandardCompare:)]];
我得到的錯誤是
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber localizedStandardCompare:]: unrecognized selector sent to instance 0x8142450'
我創建的核心數據屬性是這樣的:
dataItemOne.ordering = [NSNumber numberWithInteger:1];
哈哈是的,它現在的工作,我敢肯定,我以前試過,它沒有工作,但我想我得到了另一個錯誤。今天腦死了。謝謝您的幫助。 –