forked from magicalpanda/MagicalRecord
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shorthand method for getting the numberOfRows of a NSFetchedResultCon…
…troller section without having to do the NSFetchedResultsSectionInfo Samba.
- Loading branch information
StuFF mc
committed
Jan 26, 2013
1 parent
389fe44
commit b2706b6
Showing
3 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
MagicalRecord/Categories/NSFetchedResultsController+MagicalRecord.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// | ||
// NSFetchedResultsController+MagicalRecord.h | ||
// wetter-com-iphone | ||
// | ||
// Created by Manuel "StuFF mc" Carrasco Molina on 26.01.13. | ||
// Copyright (c) 2013 grandcentrix GmbH. All rights reserved. | ||
// | ||
|
||
#import <CoreData/CoreData.h> | ||
|
||
#if TARGET_OS_IPHONE | ||
|
||
@interface NSFetchedResultsController (MagicalRecord) | ||
|
||
- (NSInteger)MR_numberOfObjectsInSection:(NSUInteger)section; | ||
- (NSUInteger)MR_fuzzyNumberOfObjectsInSection:(NSUInteger)section; | ||
|
||
@end | ||
|
||
#endif |
34 changes: 34 additions & 0 deletions
34
MagicalRecord/Categories/NSFetchedResultsController+MagicalRecord.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// NSFetchedResultsController+MagicalRecord.m | ||
// wetter-com-iphone | ||
// | ||
// Created by Manuel "StuFF mc" Carrasco Molina on 26.01.13. | ||
// Copyright (c) 2013 grandcentrix GmbH. All rights reserved. | ||
// | ||
|
||
#import "NSFetchedResultsController+MagicalRecord.h" | ||
|
||
#if TARGET_OS_IPHONE | ||
|
||
@implementation NSFetchedResultsController (MagicalRecord) | ||
|
||
- (NSInteger)MR_numberOfObjectsInSection:(NSUInteger)section | ||
{ | ||
NSUInteger count = -1; // This means section out of index in a nicer way! | ||
if (section < self.sections.count) { | ||
id<NSFetchedResultsSectionInfo> info = self.sections[section]; | ||
count = [info numberOfObjects]; | ||
} | ||
return count; | ||
} | ||
|
||
- (NSUInteger)MR_fuzzyNumberOfObjectsInSection:(NSUInteger)section | ||
{ | ||
NSInteger count = [self MR_numberOfObjectsInSection:section]; | ||
count = (count > 0) ? count : 0; | ||
return count; | ||
} | ||
|
||
@end | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters