use crate::common::*;
use crate::CoreData::*;
use crate::Foundation::*;
__inner_extern_class!(
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct NSFetchedResultsController<
ResultType: Message = Object,
ResultTypeOwnership: Ownership = Shared,
> {
_inner0: PhantomData<*mut (ResultType, ResultTypeOwnership)>,
notunwindsafe: PhantomData<&'static mut ()>,
}
unsafe impl<ResultType: Message, ResultTypeOwnership: Ownership> ClassType
for NSFetchedResultsController<ResultType, ResultTypeOwnership>
{
type Super = NSObject;
}
);
extern_methods!(
unsafe impl<ResultType: Message, ResultTypeOwnership: Ownership>
NSFetchedResultsController<ResultType, ResultTypeOwnership>
{
#[method_id(@__retain_semantics Init initWithFetchRequest:managedObjectContext:sectionNameKeyPath:cacheName:)]
pub unsafe fn initWithFetchRequest_managedObjectContext_sectionNameKeyPath_cacheName(
this: Option<Allocated<Self>>,
fetchRequest: &NSFetchRequest<ResultType>,
context: &NSManagedObjectContext,
sectionNameKeyPath: Option<&NSString>,
name: Option<&NSString>,
) -> Id<Self, Shared>;
#[method(performFetch:)]
pub unsafe fn performFetch(&self) -> Result<(), Id<NSError, Shared>>;
#[method_id(@__retain_semantics Other fetchRequest)]
pub unsafe fn fetchRequest(&self) -> Id<NSFetchRequest<ResultType>, Shared>;
#[method_id(@__retain_semantics Other managedObjectContext)]
pub unsafe fn managedObjectContext(&self) -> Id<NSManagedObjectContext, Shared>;
#[method_id(@__retain_semantics Other sectionNameKeyPath)]
pub unsafe fn sectionNameKeyPath(&self) -> Option<Id<NSString, Shared>>;
#[method_id(@__retain_semantics Other cacheName)]
pub unsafe fn cacheName(&self) -> Option<Id<NSString, Shared>>;
#[method_id(@__retain_semantics Other delegate)]
pub unsafe fn delegate(&self) -> Option<Id<NSFetchedResultsControllerDelegate, Shared>>;
#[method(setDelegate:)]
pub unsafe fn setDelegate(&self, delegate: Option<&NSFetchedResultsControllerDelegate>);
#[method(deleteCacheWithName:)]
pub unsafe fn deleteCacheWithName(name: Option<&NSString>);
#[method_id(@__retain_semantics Other fetchedObjects)]
pub unsafe fn fetchedObjects(&self) -> Option<Id<NSArray<ResultType>, Shared>>;
#[method_id(@__retain_semantics Other objectAtIndexPath:)]
pub unsafe fn objectAtIndexPath(&self, indexPath: &NSIndexPath) -> Id<ResultType, Shared>;
#[method_id(@__retain_semantics Other indexPathForObject:)]
pub unsafe fn indexPathForObject(
&self,
object: &ResultType,
) -> Option<Id<NSIndexPath, Shared>>;
#[method_id(@__retain_semantics Other sectionIndexTitleForSectionName:)]
pub unsafe fn sectionIndexTitleForSectionName(
&self,
sectionName: &NSString,
) -> Option<Id<NSString, Shared>>;
#[method_id(@__retain_semantics Other sectionIndexTitles)]
pub unsafe fn sectionIndexTitles(&self) -> Id<NSArray<NSString>, Shared>;
#[method_id(@__retain_semantics Other sections)]
pub unsafe fn sections(&self) -> Option<Id<NSArray<NSFetchedResultsSectionInfo>, Shared>>;
#[method(sectionForSectionIndexTitle:atIndex:)]
pub unsafe fn sectionForSectionIndexTitle_atIndex(
&self,
title: &NSString,
sectionIndex: NSInteger,
) -> NSInteger;
}
);
extern_protocol!(
pub struct NSFetchedResultsSectionInfo;
unsafe impl ProtocolType for NSFetchedResultsSectionInfo {
#[method_id(@__retain_semantics Other name)]
pub unsafe fn name(&self) -> Id<NSString, Shared>;
#[method_id(@__retain_semantics Other indexTitle)]
pub unsafe fn indexTitle(&self) -> Option<Id<NSString, Shared>>;
#[method(numberOfObjects)]
pub unsafe fn numberOfObjects(&self) -> NSUInteger;
#[method_id(@__retain_semantics Other objects)]
pub unsafe fn objects(&self) -> Option<Id<NSArray, Shared>>;
}
);
ns_enum!(
#[underlying(NSUInteger)]
pub enum NSFetchedResultsChangeType {
NSFetchedResultsChangeInsert = 1,
NSFetchedResultsChangeDelete = 2,
NSFetchedResultsChangeMove = 3,
NSFetchedResultsChangeUpdate = 4,
}
);
extern_protocol!(
pub struct NSFetchedResultsControllerDelegate;
unsafe impl ProtocolType for NSFetchedResultsControllerDelegate {
#[optional]
#[method(controller:didChangeContentWithDifference:)]
pub unsafe fn controller_didChangeContentWithDifference(
&self,
controller: &NSFetchedResultsController,
diff: &NSOrderedCollectionDifference<NSManagedObjectID>,
);
#[optional]
#[method(controller:didChangeObject:atIndexPath:forChangeType:newIndexPath:)]
pub unsafe fn controller_didChangeObject_atIndexPath_forChangeType_newIndexPath(
&self,
controller: &NSFetchedResultsController,
anObject: &Object,
indexPath: Option<&NSIndexPath>,
type_: NSFetchedResultsChangeType,
newIndexPath: Option<&NSIndexPath>,
);
#[optional]
#[method(controller:didChangeSection:atIndex:forChangeType:)]
pub unsafe fn controller_didChangeSection_atIndex_forChangeType(
&self,
controller: &NSFetchedResultsController,
sectionInfo: &NSFetchedResultsSectionInfo,
sectionIndex: NSUInteger,
type_: NSFetchedResultsChangeType,
);
#[optional]
#[method(controllerWillChangeContent:)]
pub unsafe fn controllerWillChangeContent(&self, controller: &NSFetchedResultsController);
#[optional]
#[method(controllerDidChangeContent:)]
pub unsafe fn controllerDidChangeContent(&self, controller: &NSFetchedResultsController);
#[optional]
#[method_id(@__retain_semantics Other controller:sectionIndexTitleForSectionName:)]
pub unsafe fn controller_sectionIndexTitleForSectionName(
&self,
controller: &NSFetchedResultsController,
sectionName: &NSString,
) -> Option<Id<NSString, Shared>>;
}
);