我想要团队数据,因为它来自网络服务,我使用字典完成它,但它按字母顺序排序,我不想排序,我希望它显示在网络服务中。
self.searchSections = [[NSMutableDictionary alloc] init];
NSError *error = nil;
NSDictionary *xmlDict = [XMLReader dictionaryForXMLString:Str error:&error];
NSArray *leaguelist = [[[xmlDict objectForKey:@"GetLeagueNamesListOutput"] objectForKey:@"Leagues"] objectForKey:@"eLeagueMst"];
if (leaguelist.count>0)
{
if (![leaguelist isKindOfClass:[NSArray class]])
{
// if 'list' isn't an array, we create a new array containing our object
leaguelist = [NSArray arrayWithObject:leaguelist];
}
// we can loop through items safely now
for (NSDictionary *item in leaguelist)
{
NSString *c = [[item objectForKey:@"CountryName"] objectForKey:@"text"];
found = NO;
for (NSString *str in [self.searchSections allKeys])
{
if ([str isEqualToString:c])
{
found = YES;
}
}
if (!found)
{
[self.searchSections setValue:[[NSMutableArray alloc] init] forKey:c];
}
}
// Loop again and sort the books into their respective keys
for (NSDictionary *book in leaguelist)
{
[[self.searchSections objectForKey:[[book objectForKey:@"CountryName"] objectForKey:@"text"]] addObject:book];
}