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
CSListMonitor
s created without section groupings.Declaration
Swift
@objc public subscript(index: Int) -> Any { get }
Parameters
index
the index of the object. Using an index above the valid range will raise an exception.
Return Value
the
NSManagedObject
at the specified index -
Returns the object at the given index, or
nil
if out of bounds. This indexer is typically used forCSListMonitor
s created without section groupings.Declaration
Swift
@objc public func objectAtSafeIndex(_ index: Int) -> Any?
Parameters
index
the index for the object. Using an index above the valid range will return
nil
.Return Value
the
NSManagedObject
at the specified index, ornil
if out of bounds -
Returns the object at the given
sectionIndex
anditemIndex
. This indexer is typically used forCSListMonitor
s created as sectioned lists.Declaration
Swift
@objc public func objectAtSectionIndex(_ sectionIndex: Int, itemIndex: Int) -> Any
Parameters
sectionIndex
the section index for the object. Using a
sectionIndex
with an invalid range will raise an exception.itemIndex
the index for the object within the section. Using an
itemIndex
with an invalid range will raise an exception.Return Value
the
NSManagedObject
at the specified section and item index -
Returns the object at the given section and item index, or
nil
if out of bounds. This indexer is typically used forCSListMonitor
s created as sectioned lists.Declaration
Swift
@objc public func objectAtSafeSectionIndex(_ sectionIndex: Int, safeItemIndex itemIndex: Int) -> Any?
Parameters
sectionIndex
the section index for the object. Using a
sectionIndex
with an invalid range will returnnil
.itemIndex
the index for the object within the section. Using an
itemIndex
with an invalid range will returnnil
.Return Value
the
NSManagedObject
at the specified section and item index, ornil
if out of bounds -
Returns the object at the given
NSIndexPath
. This subscript indexer is typically used forCSListMonitor
s created as sectioned lists.Declaration
Swift
@objc public func objectAtIndexPath(_ indexPath: IndexPath) -> Any
Parameters
indexPath
the
NSIndexPath
for the object. Using anindexPath
with an invalid range will raise an exception.Return Value
the
NSManagedObject
at the specified index path -
Returns the object at the given
NSIndexPath
, ornil
if out of bounds. This subscript indexer is typically used forCSListMonitor
s created as sectioned lists.Declaration
Swift
@objc public func objectAtSafeIndexPath(_ indexPath: IndexPath) -> Any?
Parameters
indexPath
the
NSIndexPath
for the object. Using anindexPath
with an invalid range will returnnil
.Return Value
the
NSManagedObject
at the specified index path, ornil
if out of bounds -
Checks if the
CSListMonitor
has at least one object in any section.Declaration
Swift
@objc public func hasObjects() -> Bool
Return Value
YES
if at least one object in any section exists,NO
otherwise -
Checks if the
CSListMonitor
has at least one object the specified section.Declaration
Swift
@objc public func hasObjectsInSection(_ section: Int) -> Bool
Parameters
section
the section index. Using an index outside the valid range will return
NO
.Return Value
YES
if at least one object in the specified section exists,NO
otherwise -
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
section
the 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
nil
if out of bounds.Declaration
Swift
@objc public func objectsInSafeSection(safeSectionIndex section: Int) -> [NSManagedObject]?
Parameters
section
the section index. Using an index outside the valid range will return
nil
.Return Value
all objects in the specified section, or
nil
if out of bounds -
Returns the number of sections
Declaration
Swift
@objc public func numberOfSections() -> Int
Return Value
the number of sections
-
Returns the number of objects in all sections
Declaration
Swift
@objc public func numberOfObjects() -> Int
Return 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) -> Int
Parameters
section
the 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
nil
if out of bounds.Declaration
Swift
@objc public func numberOfObjectsInSafeSection(safeSectionIndex section: Int) -> NSNumber?
Parameters
section
the section index. Using an index outside the valid range will return
nil
.Return Value
the number of objects in the specified section, or
nil
if out of bounds -
Returns the
NSFetchedResultsSectionInfo
for the specified sectionDeclaration
Swift
@objc public func sectionInfoAtIndex(_ section: Int) -> NSFetchedResultsSectionInfo
Parameters
section
the section index. Using an index outside the valid range will raise an exception.
Return Value
the
NSFetchedResultsSectionInfo
for the specified section -
Returns the
NSFetchedResultsSectionInfo
for the specified section, ornil
if out of bounds.Declaration
Swift
@objc public func sectionInfoAtSafeSectionIndex(safeSectionIndex section: Int) -> NSFetchedResultsSectionInfo?
Parameters
section
the section index. Using an index outside the valid range will return
nil
.Return Value
the
NSFetchedResultsSectionInfo
for the specified section, ornil
if the section index is out of bounds. -
Returns the
NSFetchedResultsSectionInfo
s for all sectionsDeclaration
Swift
@objc public func sections() -> [NSFetchedResultsSectionInfo]
Return Value
the
NSFetchedResultsSectionInfo
s 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) -> Int
Parameters
title
the title of the Section Index
index
the 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
NSManagedObject
if it exists in theCSListMonitor
‘s fetched objects, ornil
if not found.Declaration
Swift
@objc public func indexOf(_ object: NSManagedObject) -> NSNumber?
Parameters
object
the
NSManagedObject
to search the index ofReturn Value
the index of the
NSManagedObject
if it exists in theCSListMonitor
‘s fetched objects, ornil
if not found. -
Returns the
NSIndexPath
of theNSManagedObject
if it exists in theCSListMonitor
‘s fetched objects, ornil
if not found.Declaration
Swift
@objc public func indexPathOf(_ object: NSManagedObject) -> IndexPath?
Parameters
object
the
NSManagedObject
to search the index ofReturn Value
the
NSIndexPath
of theNSManagedObject
if it exists in theListMonitor
‘s fetched objects, ornil
if not found.
-
Registers a
CSListObserver
to be notified when changes to the receiver’s list occur.To prevent retain-cycles,
CSListMonitor
only keepsweak
references 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, asCSListMonitor
unregisters previous notifications to the observer before re-registering them.Declaration
Swift
@objc public func addListObserver(_ observer: CSListObserver)
Parameters
observer
a
CSListObserver
to send change notifications to -
Registers a
CSListObjectObserver
to be notified when changes to the receiver’s list occur.To prevent retain-cycles,
CSListMonitor
only keepsweak
references 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, asListMonitor
unregisters previous notifications to the observer before re-registering them.Declaration
Swift
public func addListObjectObserver(_ observer: CSListObjectObserver)
Parameters
observer
a
CSListObjectObserver
to send change notifications to -
Registers a
CSListSectionObserver
to be notified when changes to the receiver’s list occur.To prevent retain-cycles,
CSListMonitor
only keepsweak
references 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, asListMonitor
unregisters previous notifications to the observer before re-registering them.Declaration
Swift
@objc public func addListSectionObserver(_ observer: CSListSectionObserver)
Parameters
observer
a
CSListSectionObserver
to send change notifications to -
Unregisters a
CSListObserver
from 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
observer
a
CSListObserver
to unregister notifications to
-
Returns
YES
if a call to-refetch:
was made to theCSListMonitor
and is currently waiting for the fetching to complete. ReturnsNO
otherwise.Declaration
Swift
@objc public var isPendingRefetch: Bool { get }
-
Asks the
CSListMonitor
to refetch its objects using the specified series ofCSFetchClause
s. 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, allCSFetchClause
s required by theCSListMonitor
should be provided in the arguments list ofrefetch(...)
.Declaration
Swift
@objc public func refetch(_ fetchClauses: [CSFetchClause])
Parameters
fetchClauses
a series of
FetchClause
instances for fetching the object list. AcceptsWhere
,OrderBy
, andTweak
clauses.