したがって、tableView
を月/年でグループ化するような古典的な状況があります。私はconference
というオブジェクトを持っていてbeginDateSearchString
というオブジェクトを持っていて、別のものを入れようとするのはconference
です。私の問題は次の部分にあります。beginDate
(これは日付です)によって各バケットを並べ替えるためにNSSortDescriptor
を使用しません。既存のNSArrayオブジェクトプロパティを使用して、セクション化されたテーブルビュー用の新しいNSArrayを作成します。
unsorted
に関連するエラーが発生しました。ソートデスクリプタタイプセレクタを受け取れません。あなたはおそらく、ソートに加えて、配列をフィルタリングする
- (NSArray *)arrayOfDateSortedEvents {
NSMutableArray *sortedArray = [[NSMutableArray alloc] init];
NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] init];
//place into buckets
for (WSConference *conference in self.arrayOfEvents) {
if (![dictionary objectForKey:[conference beginDateSearchString]]) {
NSMutableArray *array = [[NSMutableArray alloc] initWithObjects:conference,nil];
[dictionary setObject:array forKey:[conference beginDateSearchString]];
}
else {
[[dictionary objectForKey:[conference beginDateSearchString]] addObject:conference];
}
}
//sort each bucket by descriptor beginDate
NSSortDescriptor *descriptor = [[NSSortDescriptor alloc] initWithKey:@"beginDate" ascending:YES];
NSArray *sortDescriptors = [NSArray arrayWithObject:descriptor];
for (NSMutableArray *unsorted in dictionary) {
[unsorted sortUsingDescriptors:sortDescriptors];
}
// now, unkey and add dictionary in order
while ([dictionary count] > 0) {
NSString *lowest = nil;
for (NSMutableArray *array in dictionary) {
if (!lowest)
lowest = [[dictionary allKeysForObject:array] objectAtIndex:0];
else {
if ([(WSConference *)[array objectAtIndex:0] beginDate] < [[dictionary objectForKey:lowest] beginDate])
lowest = [[dictionary allKeysForObject:array] objectAtIndex:0];
}
}
[sortedArray addObject:[dictionary objectForKey:lowest]];
[dictionary removeObjectForKey:lowest];
}
return sortedArray;
}
そのアップ投げると、アレイは 'sortUsingDescriptors'を受信できない場合として動作し、なぜ任意のアイデア?実際には、 'NCSF string'型として報告します。 –
「NCSF文字列」として何が報告されていますか?「それ」がどちらであるかわかりません。 – dbrajkovic
'beginDate'プロパティは文字列かNSDateですか? – dbrajkovic