小编Pau*_*0nd的帖子

在NSFetchedResultsController中添加额外的部分

我正在为我的公司写一个小型iPhone应用程序,每次为每位员工提供一周的预订.我正在使用核心数据来获取给定周的"预订"列表,并希望将它们显示在UITableView中,分解为一周中每天的一个部分.

问题在于我需要在一周中的每一天显示7个部分(显示"没有预订"单元格,其中部分/日期没有预订).

我有一个应用程序的截图,因为它站在这里(抱歉无法发布图像,因为我是StackOverlow的新手)

目前我通过使用'fetchResults'方法来实现这一目标,该方法获取预订并将它们组织成可能日期的数组:

- (void)refetchResults {    

// Drop bookings Array, replacing with new empty one
// 7 slots for 7 days each holding mutable array to recieve bookings where appropraite
self.bookings = [NSArray arrayWithObjects:[NSMutableArray array],
                  [NSMutableArray array], [NSMutableArray array],
                  [NSMutableArray array], [NSMutableArray array],
                  [NSMutableArray array], [NSMutableArray array], nil];

// Create the fetch request for the entity.
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Booking" inManagedObjectContext:self.managedObjectContext];
[fetchRequest setEntity:entity];

// Limit to this weeks data
[fetchRequest …
Run Code Online (Sandbox Code Playgroud)

iphone core-data objective-c nsfetchedresultscontroller

6
推荐指数
2
解决办法
3235
查看次数