Class: NSFetchedResultsController
Overview
You use a fetched results controller to efficiently manage the results returned from a Core Data fetch request to provide data for a UITableView object.
Instance Attribute Summary (collapse)
-
- cacheName
readonly
The name of the file used to cache section information.
-
- delegate
The object that is notified when the fetched results changed.
-
- fetchedObjects
readonly
The results of the fetch.
-
- fetchRequest
readonly
The fetch request used to do the fetching.
-
- managedObjectContext
readonly
The managed object context used to fetch objects.
-
- sectionIndexTitles
readonly
The array of section index titles.
-
- sectionNameKeyPath
readonly
The key path on the fetched objects used to determine the section they belong to.
-
- sections
readonly
The sections for the receiver’s fetch results.
Class Method Summary (collapse)
-
+ deleteCacheWithName:
Deletes the cached section information with the given name.
Instance Method Summary (collapse)
-
- indexPathForObject:
Returns the index path of a given object.
-
- initWithFetchRequest:managedObjectContext:sectionNameKeyPath:cacheName:
Returns a fetch request controller initialized using the given arguments.
-
- objectAtIndexPath:
Returns the object at the given index path in the fetch results.
-
- performFetch:
Executes the receiver’s fetch request.
-
- sectionForSectionIndexTitle:atIndex:
Returns the section number for a given section title and index in the section index.
-
- sectionIndexTitleForSectionName:
Returns the corresponding section index entry for a given section name.
Methods inherited from NSObject
#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version
Constructor Details
This class inherits a constructor from NSObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class NSObject
Instance Attribute Details
- (String) cacheName (readonly)
The name of the file used to cache section information. The file itself is stored in a private directory; you can only access it by name using deleteCacheWithName:
- (Object) delegate
The object that is notified when the fetched results changed.
- (Array) fetchedObjects (readonly)
The results of the fetch. The value of the property is nil if performFetch: hasn’t been called.The results array only includes instances of the entity specified by the fetch request (fetchRequest) and that match its predicate. (If the fetch request has no predicate, then the results array includes all instances of the entity specified by the fetch request.)The results array reflects the in-memory state of managed objects in the controller’s managed object context, not their state in the persistent store. The returned array does not, however, update as managed objects are inserted, modified, or deleted.
- (NSFetchRequest) fetchRequest (readonly)
The fetch request used to do the fetching.
- (NSManagedObjectContext) managedObjectContext (readonly)
The managed object context used to fetch objects. The controller registers to listen to change notifications on this context and properly update its result set and section information.
- (Array) sectionIndexTitles (readonly)
The array of section index titles. The default implementation returns the array created by calling sectionIndexTitleForSectionName: on all the known sections. You should override this method if you want to return a different array for the section index.
- (String) sectionNameKeyPath (readonly)
The key path on the fetched objects used to determine the section they belong to.
- (Array) sections (readonly)
The sections for the receiver’s fetch results. The objects in the sections array implement the NSFetchedResultsSectionInfo protocol.You typically use the sections array when implementing UITableViewDataSource methods, such as numberOfSectionsInTableView: and tableView:titleForHeaderInSection:.
Class Method Details
+ (Object) deleteCacheWithName(name)
Deletes the cached section information with the given name.
Instance Method Details
- (NSIndexPath ) indexPathForObject(object)
Returns the index path of a given object.
- (Object) initWithFetchRequest(fetchRequest, managedObjectContext:context, sectionNameKeyPath:sectionNameKeyPath, cacheName:name)
Returns a fetch request controller initialized using the given arguments.
- (Object) objectAtIndexPath(indexPath)
Returns the object at the given index path in the fetch results.
- (Boolean) performFetch(error)
Executes the receiver’s fetch request. After executing this method, you can access the receiver’s the fetched objects with the property fetchedObjects.
- (Integer) sectionForSectionIndexTitle(title, atIndex:sectionIndex)
Returns the section number for a given section title and index in the section index. You would typically call this method when executing UITableViewDataSource’s tableView:sectionForSectionIndexTitle:atIndex: method.
- (NSString ) sectionIndexTitleForSectionName(sectionName)
Returns the corresponding section index entry for a given section name. The default implementation returns the capitalized first letter of the section name.You should override this method if you need a different way to convert from a section name to its name in the section index.