mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-04-22 08:48:28 +02:00
Let ListMonitor expose methods for Section Indexes (fixes #32)
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
Pod::Spec.new do |s|
|
Pod::Spec.new do |s|
|
||||||
s.name = "CoreStore"
|
s.name = "CoreStore"
|
||||||
s.version = "1.4.1"
|
s.version = "1.4.2"
|
||||||
s.license = "MIT"
|
s.license = "MIT"
|
||||||
s.summary = "Unleashing the real power of Core Data with the elegance and safety of Swift"
|
s.summary = "Unleashing the real power of Core Data with the elegance and safety of Swift"
|
||||||
s.homepage = "https://github.com/JohnEstropia/CoreStore"
|
s.homepage = "https://github.com/JohnEstropia/CoreStore"
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>FMWK</string>
|
<string>FMWK</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>1.4.1</string>
|
<string>1.4.2</string>
|
||||||
<key>CFBundleSignature</key>
|
<key>CFBundleSignature</key>
|
||||||
<string>????</string>
|
<string>????</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
|
|||||||
@@ -335,6 +335,56 @@ public final class ListMonitor<T: NSManagedObject> {
|
|||||||
return sections[section]
|
return sections[section]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the `NSFetchedResultsSectionInfo`s for all sections
|
||||||
|
|
||||||
|
- returns: the `NSFetchedResultsSectionInfo`s for all sections
|
||||||
|
*/
|
||||||
|
@warn_unused_result
|
||||||
|
public func sections() -> [NSFetchedResultsSectionInfo] {
|
||||||
|
|
||||||
|
CoreStore.assert(
|
||||||
|
!self.isPendingRefetch || NSThread.isMainThread(),
|
||||||
|
"Attempted to access a \(typeName(self)) outside the main thread while a refetch is in progress."
|
||||||
|
)
|
||||||
|
|
||||||
|
return self.fetchedResultsController.sections ?? []
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the target section for a specified "Section Index" title and index.
|
||||||
|
|
||||||
|
- parameter title: the title of the Section Index
|
||||||
|
- parameter index: the index of the Section Index
|
||||||
|
- returns: the target section for the specified "Section Index" title and index.
|
||||||
|
*/
|
||||||
|
@warn_unused_result
|
||||||
|
public func targetSectionForSectionIndex(title title: String, index: Int) -> Int {
|
||||||
|
|
||||||
|
CoreStore.assert(
|
||||||
|
!self.isPendingRefetch || NSThread.isMainThread(),
|
||||||
|
"Attempted to access a \(typeName(self)) outside the main thread while a refetch is in progress."
|
||||||
|
)
|
||||||
|
|
||||||
|
return self.fetchedResultsController.sectionForSectionIndexTitle(title, atIndex: index)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the section index titles for all sections
|
||||||
|
|
||||||
|
- returns: the section index titles for all sections
|
||||||
|
*/
|
||||||
|
@warn_unused_result
|
||||||
|
public func sectionIndexTitles() -> [String] {
|
||||||
|
|
||||||
|
CoreStore.assert(
|
||||||
|
!self.isPendingRefetch || NSThread.isMainThread(),
|
||||||
|
"Attempted to access a \(typeName(self)) outside the main thread while a refetch is in progress."
|
||||||
|
)
|
||||||
|
|
||||||
|
return self.fetchedResultsController.sectionIndexTitles
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the index of the `NSManagedObject` if it exists in the `ListMonitor`'s fetched objects, or `nil` if not found.
|
Returns the index of the `NSManagedObject` if it exists in the `ListMonitor`'s fetched objects, or `nil` if not found.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user