CSListMonitor
@available(OSX 10.12, *)
@objc
public final class CSListMonitor : NSObject
The CSListMonitor serves as the Objective-C bridging type for ListMonitor<T>.
See also
ListMonitor
-
Returns the object at the given index within the first section. This subscript indexer is typically used for
CSListMonitors created without section groupings.Declaration
Swift
@objc public subscript(index: Int) -> Any { get }Parameters
indexthe index of the object. Using an index above the valid range will raise an exception.
Return Value
the
NSManagedObjectat the specified index -
Returns the object at the given index, or
nilif out of bounds. This indexer is typically used forCSListMonitors created without section groupings.Declaration
Swift
@objc public func objectAtSafeIndex(_ index: Int) -> Any?Parameters
indexthe index for the object. Using an index above the valid range will return
nil.Return Value
the
NSManagedObjectat the specified index, ornilif out of bounds -
Returns the object at the given
sectionIndexanditemIndex. This indexer is typically used forCSListMonitors created as sectioned lists.Declaration
Swift
@objc public func objectAtSectionIndex(_ sectionIndex: Int, itemIndex: Int) -> AnyParameters
sectionIndexthe section index for the object. Using a
sectionIndexwith an invalid range will raise an exception.itemIndexthe index for the object within the section. Using an
itemIndexwith an invalid range will raise an exception.Return Value
the
NSManagedObjectat the specified section and item index -
Returns the object at the given section and item index, or
nilif out of bounds. This indexer is typically used forCSListMonitors created as sectioned lists.Declaration
Swift
@objc public func objectAtSafeSectionIndex(_ sectionIndex: Int, safeItemIndex itemIndex: Int) -> Any?Parameters
sectionIndexthe section index for the object. Using a
sectionIndexwith an invalid range will returnnil.itemIndexthe index for the object within the section. Using an
itemIndexwith an invalid range will returnnil.Return Value
the
NSManagedObjectat the specified section and item index, ornilif out of bounds -
Returns the object at the given
NSIndexPath. This subscript indexer is typically used forCSListMonitors created as sectioned lists.Declaration
Swift
@objc public func objectAtIndexPath(_ indexPath: IndexPath) -> AnyParameters
indexPaththe
NSIndexPathfor the object. Using anindexPathwith an invalid range will raise an exception.Return Value
the
NSManagedObjectat the specified index path -
Returns the object at the given
NSIndexPath, ornilif out of bounds. This subscript indexer is typically used forCSListMonitors created as sectioned lists.Declaration
Swift
@objc public func objectAtSafeIndexPath(_ indexPath: IndexPath) -> Any?Parameters
indexPaththe
NSIndexPathfor the object. Using anindexPathwith an invalid range will returnnil.Return Value
the
NSManagedObjectat the specified index path, ornilif out of bounds -
Checks if the
CSListMonitorhas at least one object in any section.Declaration
Swift
@objc public func hasObjects() -> BoolReturn Value
YESif at least one object in any section exists,NOotherwise -
Checks if the
CSListMonitorhas at least one object the specified section.Declaration
Swift
@objc public func hasObjectsInSection(_ section: Int) -> BoolParameters
sectionthe section index. Using an index outside the valid range will return
NO.Return Value
YESif at least one object in the specified section exists,NOotherwise -
Returns all objects in all sections
Declaration
Swift
@objc public func objectsInAllSections() -> [NSManagedObject]Return Value
all objects in all sections
-
Returns all objects in the specified section
Declaration
Swift
@objc public func objectsInSection(_ section: Int) -> [NSManagedObject]Parameters
sectionthe section index. Using an index outside the valid range will raise an exception.
Return Value
all objects in the specified section
-
Returns all objects in the specified section, or
nilif out of bounds.Declaration
Swift
@objc public func objectsInSafeSection(safeSectionIndex section: Int) -> [NSManagedObject]?Parameters
sectionthe section index. Using an index outside the valid range will return
nil.Return Value
all objects in the specified section, or
nilif out of bounds -
Returns the number of sections
Declaration
Swift
@objc public func numberOfSections() -> IntReturn Value
the number of sections
-
Returns the number of objects in all sections
Declaration
Swift
@objc public func numberOfObjects() -> IntReturn Value
the number of objects in all sections
-
Returns the number of objects in the specified section
Declaration
Swift
@objc public func numberOfObjectsInSection(_ section: Int) -> IntParameters
sectionthe section index. Using an index outside the valid range will raise an exception.
Return Value
the number of objects in the specified section
-
Returns the number of objects in the specified section, or
nilif out of bounds.Declaration
Swift
@objc public func numberOfObjectsInSafeSection(safeSectionIndex section: Int) -> NSNumber?Parameters
sectionthe section index. Using an index outside the valid range will return
nil.Return Value
the number of objects in the specified section, or
nilif out of bounds -
Returns the
NSFetchedResultsSectionInfofor the specified sectionDeclaration
Swift
@objc public func sectionInfoAtIndex(_ section: Int) -> NSFetchedResultsSectionInfoParameters
sectionthe section index. Using an index outside the valid range will raise an exception.
Return Value
the
NSFetchedResultsSectionInfofor the specified section -
Returns the
NSFetchedResultsSectionInfofor the specified section, ornilif out of bounds.Declaration
Swift
@objc public func sectionInfoAtSafeSectionIndex(safeSectionIndex section: Int) -> NSFetchedResultsSectionInfo?Parameters
sectionthe section index. Using an index outside the valid range will return
nil.Return Value
the
NSFetchedResultsSectionInfofor the specified section, ornilif the section index is out of bounds. -
Returns the
NSFetchedResultsSectionInfos for all sectionsDeclaration
Swift
@objc public func sections() -> [NSFetchedResultsSectionInfo]Return Value
the
NSFetchedResultsSectionInfos for all sections -
Returns the target section for a specified
Section Index
title and index.Declaration
Swift
@objc public func targetSectionForSectionIndexTitle(title: String, index: Int) -> IntParameters
titlethe title of the Section Index
indexthe index of the Section Index
Return Value
the target section for the specified
Section Index
title and index. -
Returns the section index titles for all sections
Declaration
Swift
@objc public func sectionIndexTitles() -> [String]Return Value
the section index titles for all sections
-
Returns the index of the
NSManagedObjectif it exists in theCSListMonitor‘s fetched objects, ornilif not found.Declaration
Swift
@objc public func indexOf(_ object: NSManagedObject) -> NSNumber?Parameters
objectthe
NSManagedObjectto search the index ofReturn Value
the index of the
NSManagedObjectif it exists in theCSListMonitor‘s fetched objects, ornilif not found. -
Returns the
NSIndexPathof theNSManagedObjectif it exists in theCSListMonitor‘s fetched objects, ornilif not found.Declaration
Swift
@objc public func indexPathOf(_ object: NSManagedObject) -> IndexPath?Parameters
objectthe
NSManagedObjectto search the index ofReturn Value
the
NSIndexPathof theNSManagedObjectif it exists in theListMonitor‘s fetched objects, ornilif not found.
-
Registers a
CSListObserverto be notified when changes to the receiver’s list occur.To prevent retain-cycles,
CSListMonitoronly keepsweakreferences to its observers.For thread safety, this method needs to be called from the main thread. An assertion failure will occur (on debug builds only) if called from any thread other than the main thread.
Calling
-addListObserver:multiple times on the same observer is safe, asCSListMonitorunregisters previous notifications to the observer before re-registering them.Declaration
Swift
@objc public func addListObserver(_ observer: CSListObserver)Parameters
observera
CSListObserverto send change notifications to -
Registers a
CSListObjectObserverto be notified when changes to the receiver’s list occur.To prevent retain-cycles,
CSListMonitoronly keepsweakreferences to its observers.For thread safety, this method needs to be called from the main thread. An assertion failure will occur (on debug builds only) if called from any thread other than the main thread.
Calling
-addListObjectObserver:multiple times on the same observer is safe, asListMonitorunregisters previous notifications to the observer before re-registering them.Declaration
Swift
public func addListObjectObserver(_ observer: CSListObjectObserver)Parameters
observera
CSListObjectObserverto send change notifications to -
Registers a
CSListSectionObserverto be notified when changes to the receiver’s list occur.To prevent retain-cycles,
CSListMonitoronly keepsweakreferences to its observers.For thread safety, this method needs to be called from the main thread. An assertion failure will occur (on debug builds only) if called from any thread other than the main thread.
Calling
-addListSectionObserver:multiple times on the same observer is safe, asListMonitorunregisters previous notifications to the observer before re-registering them.Declaration
Swift
@objc public func addListSectionObserver(_ observer: CSListSectionObserver)Parameters
observera
CSListSectionObserverto send change notifications to -
Unregisters a
CSListObserverfrom receiving notifications for changes to the receiver’s list.For thread safety, this method needs to be called from the main thread. An assertion failure will occur (on debug builds only) if called from any thread other than the main thread.
Declaration
Swift
@objc public func removeListObserver(_ observer: CSListObserver)Parameters
observera
CSListObserverto unregister notifications to
-
Returns
YESif a call to-refetch:was made to theCSListMonitorand is currently waiting for the fetching to complete. ReturnsNOotherwise.Declaration
Swift
@objc public var isPendingRefetch: Bool { get } -
Asks the
CSListMonitorto refetch its objects using the specified series ofCSFetchClauses. Note that this method does not execute the fetch immediately; the actual fetching will happen after theNSFetchedResultsController‘s lastcontrollerDidChangeContent(_:)notification completes.refetch(...)broadcastslistMonitorWillRefetch(...)to its observers immediately, and thenlistMonitorDidRefetch(...)after the new fetch request completes.Important
Starting CoreStore 4.0, allCSFetchClauses required by theCSListMonitorshould be provided in the arguments list ofrefetch(...).Declaration
Swift
@objc public func refetch(_ fetchClauses: [CSFetchClause])Parameters
fetchClausesa series of
FetchClauseinstances for fetching the object list. AcceptsWhere,OrderBy, andTweakclauses.
View on GitHub
CSListMonitor Class Reference