Весь новый код, я понятия не имею, почему это не работает. Он загружает таблицу со всеми моими данными, а не только в алфавитном порядке ...
ОБНОВЛЕНИЕ: добавлена структура данных:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>Rows</key>
<array>
<dict>
<key>Subtree</key>
<array>
<string>Address</string>
<string>Tuesday</string>
<string>Information</string>
<integer>36</integer>
<integer>-118</integer>
<string>Place LA</string>
<string>California</string>
</array>
<key>Title</key>
<string>California</string>
</dict>
<dict>
<key>Subtree</key>
<array>
<string>Address</string>
<string>Sunday</string>
<string>Information</string>
<integer>40</integer>
<integer>-72</integer>
<string>NY Place</string>
<string>New York</string>
</array>
<key>Title</key>
<string>New York</string>
</dict>
<dict>
<key>Subtree</key>
<array>
<string>Address</string>
<string>Sunday</string>
<string>Information</string>
<integer>30</integer>
<integer>-97</integer>
<string>Austin Place</string>
<string>Texas</string>
</array>
<key>Title</key>
<string>Texas</string>
</dict>
<dict>
<key>Subtree</key>
<array>
<string>Address</string>
<string>Wednesday</string>
<string>Information</string>
<integer>30</integer>
<integer>-97</integer>
<string>Cleveland Place</string>
<string>Ohio</string>
</array>
<key>Title</key>
<string>Ohio</string>
</dict>
</array>
</dict>
</array>
</plist>
- (void)viewDidLoad {
[super viewDidLoad];
if (!self.tableData)
{
[self sortedArray];
self.title = @"Title"
}
}
-(NSArray *)sortedArray
{
NSString *path = [[NSBundle
mainBundle]pathForResource:@"Data3" ofType:@"plist"];
tableData = [NSArray arrayWithContentsOfFile:path];
NSArray *rows = [[tableData objectAtIndex:0]objectForKey:@"Rows"];
NSArray *rows2 = [[rows objectAtIndex:0]objectForKey:@"Subtree"];
NSString *states = [NSString stringWithFormat:@"%@",[rows2 objectAtIndex:6]];
NSString *days = [NSString stringWithFormat:@"%@",[rows2 objectAtIndex:1]];
NSSortDescriptor *stateDescriptor = [[NSSortDescriptor alloc]initWithKey:states ascending:YES];
NSSortDescriptor *dayDescriptor = [[NSSortDescriptor alloc]initWithKey:days ascending:YES];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:stateDescriptor, dayDescriptor, nil];
NSArray *finalArray = [tableData sortedArrayUsingDescriptors:sortDescriptors];
return finalArray;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.font = [UIFont fontWithName:@"MarkerFelt-Thin" size:24];
cell.textLabel.text = [[[[tableData objectAtIndex: indexPath.section] objectForKey: @"Rows"] objectAtIndex: indexPath.row] objectForKey: @"Title"];
cell.detailTextLabel.font = [UIFont fontWithName:@"MarkerFelt-Thin" size:14];
cell.detailTextLabel.text = [[[[[tableData objectAtIndex: indexPath.section] objectForKey: @"Rows"] objectAtIndex: indexPath.row] objectForKey: @"Subtree"]objectAtIndex:0];
return cell;
}