您可以创建一个请求以仅返回给定范围内的费用:
//Not tested
NSDateComponents* comps = [[NSDateComponents alloc] init];
NSCalendar* cal = [NSCalendar currentCalendar];
NSInteger year,month;//set these as you like
[comps setYear:year];
[comps setMonth:month];
NSDate* start = [cal dateFromComponents:comps];
month += 1;
month = (month <= 12 ? : 1);
[comps setMonth:month];
NSDate* end = [cal dateFromComponents:comps];
NSPredicate* predicate = [NSPredicate predicateWithFormat:@"date > %@ AND date < %@",start,end];
NSFetchRequest* request = [[NSFetchRequest alloc] initWithEntityName:@"Expense"];
[request setPredicate:predicate];
然后使用 aNSFetchedResultsController
填充您的表格视图