我正在对我的 TableView 单元格进行排序,但由于某种原因它无法正常工作。我有一个完全相同的代码和完全相同的 PLIST 的早期版本,但我可以发誓它工作了几个月。现在它拒绝排序。
numberOfRowsInSection 方法内的排序代码:
NSString *date = [self.months objectAtIndex:sectionNumber];
NSDictionary *monthData = [self.sportDictionary objectForKey:date];
NSSortDescriptor *sortDescriptor2 = [[NSSortDescriptor alloc] initWithKey: nil ascending: YES];
NSArray *days = (NSArray *)[[monthData allKeys]sortedArrayUsingDescriptors:[NSArray arrayWithObject:sortDescriptor2]];
for(int x = 0; x < [days count]; x++)
{
NSLog(@"Day: %@", [days objectAtIndex:x]);
}
当我查看 NSLog 的输出时,这是不对的。获得 15、22、29、3、8
它正在排序的 PList 部分如下所示:
<dict>
<key>1 September 2012</key>
<dict>
<key>3</key>
<array>
<string>Georgia Tech (Orange Effect)</string>
<string>8:00 PM </string>
<string>Home</string>
</array>
<key>8</key>
<array>
<string>Austin Peay (White Effect)</string>
<string>1:30 PM</string>
<string>Home</string>
</array>
<key>15</key>
<array>
<string>Pittsburgh (White Effect)</string>
<string>12:00 PM</string>
<string>Away</string>
</array>
<key>22</key>
<array>
<string>Bowling Green</string>
<string>TBA</string>
<string>Home</string>
</array>
<key>29</key>
<array>
<string>Cincinnati</string>
<string>TBA</string>
<string>Away</string>
</array>
</dict>
谢谢你,我真的很感谢你的帮助!