在我的 json 文件中,我有一个title,subtitle和url.
我对 进行排序title以按字母顺序设置项目,但url没有用 排序,title我不知道为什么。
这就是我所做的:
NSDictionary *allDataDictionary = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:nil];
NSArray *arrayOfItems = [allDataDictionary objectForKey:@"items"];
for (NSDictionary *diction in arrayOfItems) {
NSString *titles = [diction objectForKey:@"title"];
NSString *station = [diction objectForKey:@"url"];
[jsonArray addObject:titles];
[jsonStations addObject:station];
// SORT JSON
NSArray *sortedArray;
sortedArray = [jsonArray sortedArrayUsingComparator:^NSComparisonResult(NSString *title1, NSString *title2)
{
if ([title1 compare:title2] > 0)
return NSOrderedDescending;
else
return NSOrderedAscending;
}];
[jsonArray setArray:sortedArray];
当我按下 tableView 中的第一个项目时,我得到了url来自 total diffrent 的title。我应该怎么做才能title匹配urltableView中的?