Non-Terra Data Data in Basic Data-Supported UITableView

Take a look at Music.app (or iPod.app). The root album has the line "All songs." In the root view of "Songs" is the line "Shuffle". In the root view of "Playlists" is the line "Add playlist ...". Static data mixed in the same UITableView with (presumably) Core Data. I wonder how Apple achieved this.

I tried two different approaches, both failed. Like Music.app, my views also have a UISeachBar in the tableHeaderView. My first attempt kept track of the number of β€œstatic” rows I had, and adjusted the indexPath provided to various UITableView and NSFetchedResultsController methods that require section and row information. Everything worked fine until I implemented the NSFetchedResultsControllerDelegate methods to allow creation, editing and deletion. The method insertRowsAtIndexPaths:withRowAnimation:(and similar) will work on my configured indexPaths. By default, indexPaths do not work the same as.

My second attempt was to nest another UITableView in the tableHeaderView of my main UITableView for use for static rows (and to put the UISeachBar in it own tableHeaderView). This approach has not even reached the editable stage. The UISearchBar ends with overlapping the root UITableView sectionIndex scrubber and no longer slides behind the UINavigationBar when scrolling through a short list.

Therefore, instead of diagnosing my specific problems, I ask for suggestions on how Apple achieves this. Can they retrieve data once, cache it in NSArray and build a nested NSArray of sections and rows that includes both static and main data rows?

+5
source share
2

. (All Songs). , 0, . 0 1, 1 2 ..

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return [_fetchedResultsController sections] + 1;
}

- (NSInteger)tableView:(UITableView *)tv numberOfRowsInSection:(NSInteger)section {
    if( section == 0 ) {
        return 1;
    }
    id <NSFetchedResultsSectionInfo> sectionInfo = [[_fetchedResultsController sections] objectAtIndex:section-1];
    return [sectionInfo numberOfObjects];
}

- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    // All Charts
    if( indexPath.section == 0 && indexPath.row == 0 ) {
        // Set up the custom cell
    }
    // Sets
    else {
        // Set up the core data cells
    }
}

- indexPath ..

+3

( ). iPod.app, -, NSFetchedResultsControllerDelegate. , iPod.app , ? , create/edit/reorder .

, , indexPath.

, . Apple API: , . bugreport, , , - , - , , .

, , NSArrays, , , , .

, , , . , , . , , , , CoreData . , UITableView [cursor objectAtIndex: blah], . .

Sujal

+1

All Articles