Other Type Definitions
The following type definitions are available globally.
-
Undocumented
Declaration
Objective-C
typedef void (^NetworkReachableBlock)(YapReachability * reachability)
Swift
typealias NetworkReachableBlock = (YapReachability?) -> Void
-
Undocumented
Declaration
Objective-C
typedef void (^NetworkUnreachableBlock)(YapReachability * reachability)
Swift
typealias NetworkUnreachableBlock = (YapReachability?) -> Void
-
Undocumented
Declaration
Objective-C
typedef void (^YapActionItemBlock)(NSString *collection, NSString *key, id object, _Nullable id metadata)
Swift
typealias YapActionItemBlock = (String, String, Any, Any?) -> Void
-
Undocumented
Declaration
Objective-C
typedef NSArray<YapActionItem*> *_Nullable (^YapActionScheduler)(NSString *collection, NSString *key, id object)
Swift
typealias YapActionScheduler = (String, String, Any) -> [YapActionItem]?
-
Undocumented
Declaration
Objective-C
typedef id YapDatabaseViewGroupingBlock
Swift
typealias YapDatabaseViewGroupingBlock = AnyObject
-
Undocumented
Declaration
Objective-C
typedef NSString* _Nullable (^YapDatabaseViewGroupingWithKeyBlock) (YapDatabaseReadTransaction *transaction, NSString *collection, NSString *key)
Swift
typealias YapDatabaseViewGroupingWithKeyBlock = (YapDatabaseReadTransaction, String, String) -> String?
-
Undocumented
Declaration
Objective-C
typedef NSString* _Nullable (^YapDatabaseViewGroupingWithObjectBlock) (YapDatabaseReadTransaction *transaction, NSString *collection, NSString *key, id object)
Swift
typealias YapDatabaseViewGroupingWithObjectBlock = (YapDatabaseReadTransaction, String, String, Any) -> String?
-
Undocumented
Declaration
Objective-C
typedef NSString* _Nullable (^YapDatabaseViewGroupingWithMetadataBlock) (YapDatabaseReadTransaction *transaction, NSString *collection, NSString *key, _Nullable id metadata)
Swift
typealias YapDatabaseViewGroupingWithMetadataBlock = (YapDatabaseReadTransaction, String, String, Any?) -> String?
-
Undocumented
Declaration
Objective-C
typedef NSString* _Nullable (^YapDatabaseViewGroupingWithRowBlock) (YapDatabaseReadTransaction *transaction, NSString *collection, NSString *key, id object, _Nullable id metadata)
Swift
typealias YapDatabaseViewGroupingWithRowBlock = (YapDatabaseReadTransaction, String, String, Any, Any?) -> String?
-
Undocumented
Declaration
Objective-C
typedef id YapDatabaseViewSortingBlock
Swift
typealias YapDatabaseViewSortingBlock = AnyObject
-
Undocumented
Declaration
Objective-C
typedef NSComparisonResult (^YapDatabaseViewSortingWithKeyBlock) (YapDatabaseReadTransaction *transaction, NSString *group, NSString *collection1, NSString *key1, NSString *collection2, NSString *key2)
Swift
typealias YapDatabaseViewSortingWithKeyBlock = (YapDatabaseReadTransaction, String, String, String, String, String) -> ComparisonResult
-
Undocumented
Declaration
Objective-C
typedef NSComparisonResult (^YapDatabaseViewSortingWithObjectBlock) (YapDatabaseReadTransaction *transaction, NSString *group, NSString *collection1, NSString *key1, id object1, NSString *collection2, NSString *key2, id object2)
Swift
typealias YapDatabaseViewSortingWithObjectBlock = (YapDatabaseReadTransaction, String, String, String, Any, String, String, Any) -> ComparisonResult
-
Undocumented
Declaration
Objective-C
typedef NSComparisonResult (^YapDatabaseViewSortingWithMetadataBlock) (YapDatabaseReadTransaction *transaction, NSString *group, NSString *collection1, NSString *key1, _Nullable id metadata, NSString *collection2, NSString *key2, _Nullable id metadata2)
Swift
typealias YapDatabaseViewSortingWithMetadataBlock = (YapDatabaseReadTransaction, String, String, String, Any?, String, String, Any?) -> ComparisonResult
-
Undocumented
Declaration
Objective-C
typedef NSComparisonResult (^YapDatabaseViewSortingWithRowBlock) (YapDatabaseReadTransaction *transaction, NSString *group, NSString *collection1, NSString *key1, id object1, _Nullable id metadata1, NSString *collection2, NSString *key2, id object2, _Nullable id metadata2)
Swift
typealias YapDatabaseViewSortingWithRowBlock = (YapDatabaseReadTransaction, String, String, String, Any, Any?, String, String, Any, Any?) -> ComparisonResult
-
Undocumented
Declaration
Objective-C
typedef id YapDatabaseViewFindBlock
Swift
typealias YapDatabaseViewFindBlock = AnyObject
-
Undocumented
Declaration
Objective-C
typedef NSComparisonResult (^YapDatabaseViewFindWithKeyBlock) (NSString *collection, NSString *key)
Swift
typealias YapDatabaseViewFindWithKeyBlock = (String, String) -> ComparisonResult
-
Undocumented
Declaration
Objective-C
typedef NSComparisonResult (^YapDatabaseViewFindWithObjectBlock) (NSString *collection, NSString *key, id object)
Swift
typealias YapDatabaseViewFindWithObjectBlock = (String, String, Any) -> ComparisonResult
-
Undocumented
Declaration
Objective-C
typedef NSComparisonResult (^YapDatabaseViewFindWithMetadataBlock) (NSString *collection, NSString *key, _Nullable id metadata)
Swift
typealias YapDatabaseViewFindWithMetadataBlock = (String, String, Any?) -> ComparisonResult
-
Undocumented
Declaration
Objective-C
typedef NSComparisonResult (^YapDatabaseViewFindWithRowBlock) (NSString *collection, NSString *key, id object, _Nullable id metadata)
Swift
typealias YapDatabaseViewFindWithRowBlock = (String, String, Any, Any?) -> ComparisonResult
-
Serialization/Deserialization for operation objects.
The default version uses NSCoding. However, an alternative may be substitued if desired.
Declaration
Objective-C
typedef NSData *_Nonnull (^YDBCloudCoreOperationSerializer)( YapDatabaseCloudCoreOperation *_Nonnull)
Swift
typealias YDBCloudCoreOperationSerializer = (YapDatabaseCloudCoreOperation) -> Data
-
Undocumented
Declaration
Objective-C
typedef YapDatabaseCloudCoreOperation*_Nonnull (^YDBCloudCoreOperationDeserializer)(NSData *operationBlob)
Swift
typealias YDBCloudCoreOperationDeserializer = (Data) -> YapDatabaseCloudCoreOperation
-
Undocumented
Declaration
Objective-C
typedef id YapDatabaseCloudKitRecordBlock
Swift
typealias YapDatabaseCloudKitRecordBlock = AnyObject
-
Undocumented
Declaration
Objective-C
typedef void (^YapDatabaseCloudKitRecordWithKeyBlock) (YapDatabaseReadTransaction *transaction, CKRecord *_Nullable *_Nonnull inOutRecordPtr, YDBCKRecordInfo *recordInfo, NSString *collection, NSString *key)
Swift
typealias YapDatabaseCloudKitRecordWithKeyBlock = (YapDatabaseReadTransaction, AutoreleasingUnsafeMutablePointer<CKRecord?>, YDBCKRecordInfo, String, String) -> Void
-
Undocumented
Declaration
Objective-C
typedef void (^YapDatabaseCloudKitRecordWithObjectBlock) (YapDatabaseReadTransaction *transaction, CKRecord *_Nullable *_Nonnull inOutRecordPtr, YDBCKRecordInfo *recordInfo, NSString *collection, NSString *key, id object)
Swift
typealias YapDatabaseCloudKitRecordWithObjectBlock = (YapDatabaseReadTransaction, AutoreleasingUnsafeMutablePointer<CKRecord?>, YDBCKRecordInfo, String, String, Any) -> Void
-
Undocumented
Declaration
Objective-C
typedef void (^YapDatabaseCloudKitRecordWithMetadataBlock) (YapDatabaseReadTransaction *transaction, CKRecord *_Nullable *_Nonnull inOutRecordPtr, YDBCKRecordInfo *recordInfo, NSString *collection, NSString *key, __nullable id metadata)
Swift
typealias YapDatabaseCloudKitRecordWithMetadataBlock = (YapDatabaseReadTransaction, AutoreleasingUnsafeMutablePointer<CKRecord?>, YDBCKRecordInfo, String, String, Any?) -> Void
-
Undocumented
Declaration
Objective-C
typedef void (^YapDatabaseCloudKitRecordWithRowBlock) (YapDatabaseReadTransaction *transaction, CKRecord *_Nullable *_Nonnull inOutRecordPtr, YDBCKRecordInfo *recordInfo, NSString *collection, NSString *key, id object, __nullable id metadata)
Swift
typealias YapDatabaseCloudKitRecordWithRowBlock = (YapDatabaseReadTransaction, AutoreleasingUnsafeMutablePointer<CKRecord?>, YDBCKRecordInfo, String, String, Any, Any?) -> Void
-
The MergeBlock is used to merge a CKRecord, which may come from a different device or different user, into the local system.
The MergeBlock is used to perform two tasks:
- It allows you to merge changes (generally made on a different machine) into your local data model object.
- It allows you to modify YapDatabaseCloudKit’s change-set queue in the event there are any conflicts.
For more information & sample code, please see the wiki: https://github.com/yapstudios/YapDatabase/wiki/YapDatabaseCloudKit#MergeBlock
Declaration
Objective-C
typedef void (^YapDatabaseCloudKitMergeBlock)( YapDatabaseReadWriteTransaction *_Nonnull, NSString *_Nullable, NSString *_Nullable, CKRecord *_Nonnull, YDBCKMergeInfo *_Nonnull)
Swift
typealias YapDatabaseCloudKitMergeBlock = (YapDatabaseReadWriteTransaction, String?, String?, CKRecord, YDBCKMergeInfo) -> Void
-
When YapDatabaseCloudKit goes to push a change-set to the server, it creates a CKModifyRecordsOperation. If that operation comes back with an error from the CloudKit Framework, then YapDatabaseCloudKit automatically suspends itself, and forwards the error to you via the OperationErrorBlock.
It’s your job to look at the errorCode, decide what to do, and resume YapDatabaseCloudKit when ready.
For more information, please see the wiki: https://github.com/yapstudios/YapDatabase/wiki/YapDatabaseCloudKit#OperationErrorBlock
Declaration
Objective-C
typedef void (^YapDatabaseCloudKitOperationErrorBlock)(NSString *_Nonnull, NSError *_Nonnull)
Swift
typealias YapDatabaseCloudKitOperationErrorBlock = (String, Error) -> Void
-
DatabaseIdentifier Block.
CloudKit supports multiple databases. There is the privateCloudDatabase & publicCloudDatabase of the defaultContainer. In addition to this, apps may be configured with access to other (non-default) containers.
In order to properly support multiple databases, the DatabaseIdentifier block is used. Here’s how it works:
The recordHandler block is used to provide a CKRecord for a given row in the database. In addition to the CKRecord, you may also specify a ‘databaseIdentifier’ via the YDBCKRecordInfo parameter. If you specify a databaseIdentifier, then this method will be used in order to get an appropriate CKDatabase instance for the databaseIdentifier you specified.
If you ONLY use [[CKContainer defaultContainer] privateCloudDatabase], then you do NOT need to specify a DatabaseIdentifierBlock.
That is, if you never specify a databaseIdentifier for any records (you leave recordInfo.databaseIdentifier nil), then YapDatabaseCloudKit will assume & use [[CKContainer defaultContainer] privateCloudDatabase] for every CKRecord.
However, if you intend to use any other CKDatabase, the you MUST provide a DatabaseIdentifierBlock.
For more information & sample code, please see the wiki: https://github.com/yapstudios/YapDatabase/wiki/YapDatabaseCloudKit#The_databaseIdentifier
Declaration
Objective-C
typedef CKDatabase *_Nullable (^YapDatabaseCloudKitDatabaseIdentifierBlock)( NSString *_Nonnull)
Swift
typealias YapDatabaseCloudKitDatabaseIdentifierBlock = (String) -> CKDatabase?
-
Undocumented
Declaration
Objective-C
typedef id YapDatabaseViewFilteringBlock
Swift
typealias YapDatabaseViewFilteringBlock = AnyObject
-
Undocumented
Declaration
Objective-C
typedef BOOL (^YapDatabaseViewFilteringWithKeyBlock) (YapDatabaseReadTransaction *transaction, NSString *group, NSString *collection, NSString *key)
Swift
typealias YapDatabaseViewFilteringWithKeyBlock = (YapDatabaseReadTransaction, String, String, String) -> Bool
-
Undocumented
Declaration
Objective-C
typedef BOOL (^YapDatabaseViewFilteringWithObjectBlock) (YapDatabaseReadTransaction *transaction, NSString *group, NSString *collection, NSString *key, id object)
Swift
typealias YapDatabaseViewFilteringWithObjectBlock = (YapDatabaseReadTransaction, String, String, String, Any) -> Bool
-
Undocumented
Declaration
Objective-C
typedef BOOL (^YapDatabaseViewFilteringWithMetadataBlock) (YapDatabaseReadTransaction *transaction, NSString *group, NSString *collection, NSString *key, __nullable id metadata)
Swift
typealias YapDatabaseViewFilteringWithMetadataBlock = (YapDatabaseReadTransaction, String, String, String, Any?) -> Bool
-
Undocumented
Declaration
Objective-C
typedef BOOL (^YapDatabaseViewFilteringWithRowBlock) (YapDatabaseReadTransaction *transaction, NSString *group, NSString *collection, NSString *key, id object, __nullable id metadata)
Swift
typealias YapDatabaseViewFilteringWithRowBlock = (YapDatabaseReadTransaction, String, String, String, Any, Any?) -> Bool
-
Undocumented
Declaration
Objective-C
typedef id YapDatabaseFullTextSearchBlock
Swift
typealias YapDatabaseFullTextSearchBlock = AnyObject
-
Undocumented
Declaration
Objective-C
typedef void (^YapDatabaseFullTextSearchWithKeyBlock) (YapDatabaseReadTransaction *transaction, NSMutableDictionary *dict, NSString *collection, NSString *key)
Swift
typealias YapDatabaseFullTextSearchWithKeyBlock = (YapDatabaseReadTransaction, NSMutableDictionary, String, String) -> Void
-
Undocumented
Declaration
Objective-C
typedef void (^YapDatabaseFullTextSearchWithObjectBlock) (YapDatabaseReadTransaction *transaction, NSMutableDictionary *dict, NSString *collection, NSString *key, id object)
Swift
typealias YapDatabaseFullTextSearchWithObjectBlock = (YapDatabaseReadTransaction, NSMutableDictionary, String, String, Any) -> Void
-
Undocumented
Declaration
Objective-C
typedef void (^YapDatabaseFullTextSearchWithMetadataBlock) (YapDatabaseReadTransaction *transaction, NSMutableDictionary *dict, NSString *collection, NSString *key, __nullable id metadata)
Swift
typealias YapDatabaseFullTextSearchWithMetadataBlock = (YapDatabaseReadTransaction, NSMutableDictionary, String, String, Any?) -> Void
-
Undocumented
Declaration
Objective-C
typedef void (^YapDatabaseFullTextSearchWithRowBlock) (YapDatabaseReadTransaction *transaction, NSMutableDictionary *dict, NSString *collection, NSString *key, id object, __nullable id metadata)
Swift
typealias YapDatabaseFullTextSearchWithRowBlock = (YapDatabaseReadTransaction, NSMutableDictionary, String, String, Any, Any?) -> Void
-
WillModify & DidModify
Corresponds to the following method(s) in YapDatabaseReadWriteTransaction:
- setObject:forKey:inCollection:
- setObject:forKey:inCollection:withMetadata:
- setObject:forKey:inCollection:withMetadata:serializedObject:serializedMetadata:
- replaceObject:forKey:inCollection:
- replaceObject:forKey:inCollection:withSerializedObject:
- replaceMetadata:forKey:inCollection:
- replaceMetadata:forKey:inCollection:withSerializedMetadata:
The WillModifyRow & DidModifyRow allow you to listen for inserts & updates to rows in the database.
Why is a proxy used to pass the object & metadata parameters? If the setObject:forKey:inCollection: family of methods is used, then the object & key are directly available, and the proxy acts as simply a wrapper for the object or key. That is, proxy.isRealObjectLoaded will be YES. However, if the replaceObject:forKey:inCollection: family of methods are used, then the object is immediately available, but the metadata isn’t. Thus the proxy is used to lazily load the metadata, if needed. This allows a common API to support all scenarios.
Declaration
Objective-C
typedef void (^YDBHooks_WillModifyRow)( YapDatabaseReadWriteTransaction *_Nonnull, NSString *_Nonnull, NSString *_Nonnull, YapProxyObject *_Nonnull, YapProxyObject *_Nonnull, YapDatabaseHooksBitMask)
Swift
typealias YDBHooks_WillModifyRow = (YapDatabaseReadWriteTransaction, String, String, YapProxyObject, YapProxyObject, YapDatabaseHooksBitMask) -> Void
-
Undocumented
Declaration
Objective-C
typedef void (^YDBHooks_DidModifyRow) (YapDatabaseReadWriteTransaction *transaction, NSString *collection, NSString *key, YapProxyObject *proxyObject, YapProxyObject *proxyMetadata, YapDatabaseHooksBitMask flags)
Swift
typealias YDBHooks_DidModifyRow = (YapDatabaseReadWriteTransaction, String, String, YapProxyObject, YapProxyObject, YapDatabaseHooksBitMask) -> Void
-
WillRemoveRow & DidRemoveRow
Corresponds to the following method(s) in YapDatabaseReadWriteTransaction:
- removeObjectForKey:inCollection:
- removeObjectsForKeys:inCollection:
- removeAllObjectsInCollection:
Note: This method is NOT invoked if the entire database is cleared. That is, if removeAllObjectsInAllCollections is invoked.
Declaration
Objective-C
typedef void (^YDBHooks_WillRemoveRow)( YapDatabaseReadWriteTransaction *_Nonnull, NSString *_Nonnull, NSString *_Nonnull)
Swift
typealias YDBHooks_WillRemoveRow = (YapDatabaseReadWriteTransaction, String, String) -> Void
-
Undocumented
Declaration
Objective-C
typedef void (^YDBHooks_DidRemoveRow) (YapDatabaseReadWriteTransaction *transaction, NSString *collection, NSString *key)
Swift
typealias YDBHooks_DidRemoveRow = (YapDatabaseReadWriteTransaction, String, String) -> Void
-
Corresponds to the following method(s) in YapDatabaseReadWriteTransaction:
- removeAllObjectsInAllCollections
Declaration
Objective-C
typedef void (^YDBHooks_WillRemoveAllRows)( YapDatabaseReadWriteTransaction *_Nonnull)
Swift
typealias YDBHooks_WillRemoveAllRows = (YapDatabaseReadWriteTransaction) -> Void
-
Undocumented
Declaration
Objective-C
typedef void (^YDBHooks_DidRemoveAllRows) (YapDatabaseReadWriteTransaction *transaction)
Swift
typealias YDBHooks_DidRemoveAllRows = (YapDatabaseReadWriteTransaction) -> Void
-
Undocumented
Declaration
Objective-C
typedef id YapDatabaseRTreeIndexBlock
Swift
typealias YapDatabaseRTreeIndexBlock = AnyObject
-
Undocumented
Declaration
Objective-C
typedef void (^YapDatabaseRTreeIndexWithKeyBlock) (NSMutableDictionary *dict, NSString *collection, NSString *key)
Swift
typealias YapDatabaseRTreeIndexWithKeyBlock = (NSMutableDictionary, String, String) -> Void
-
Undocumented
Declaration
Objective-C
typedef void (^YapDatabaseRTreeIndexWithObjectBlock) (NSMutableDictionary *dict, NSString *collection, NSString *key, id object)
Swift
typealias YapDatabaseRTreeIndexWithObjectBlock = (NSMutableDictionary, String, String, Any) -> Void
-
Undocumented
Declaration
Objective-C
typedef void (^YapDatabaseRTreeIndexWithMetadataBlock) (NSMutableDictionary *dict, NSString *collection, NSString *key, __nullable id metadata)
Swift
typealias YapDatabaseRTreeIndexWithMetadataBlock = (NSMutableDictionary, String, String, Any?) -> Void
-
Undocumented
Declaration
Objective-C
typedef void (^YapDatabaseRTreeIndexWithRowBlock) (NSMutableDictionary *dict, NSString *collection, NSString *key, id object, __nullable id metadata)
Swift
typealias YapDatabaseRTreeIndexWithRowBlock = (NSMutableDictionary, String, String, Any, Any?) -> Void
-
The FileURLSerializer & FileURLDeserializer are used to convert between NSURL and the (serialized) blob (of bytes) that goes into the database.
By default the system converts the NSURL to a
bookmark
so that, even if the file is moved, the deserialized NSURL will point to the new filePath.You can override this behavior to achieve alternative goals.
See
defaultFileURLSerializerSee
defaultFileURLDeserializerDeclaration
Objective-C
typedef NSData *_Nullable (^YapDatabaseRelationshipFileURLSerializer)( YapDatabaseRelationshipEdge *_Nonnull)
Swift
typealias YapDatabaseRelationshipFileURLSerializer = (YapDatabaseRelationshipEdge) -> Data?
-
Undocumented
Declaration
Objective-C
typedef NSURL* _Nullable (^YapDatabaseRelationshipFileURLDeserializer)(YapDatabaseRelationshipEdge *edge, NSData *data)
Swift
typealias YapDatabaseRelationshipFileURLDeserializer = (YapDatabaseRelationshipEdge, Data) -> URL?
-
Starting with v2.8, YapDatabaseRelationship extension uses NSURL to represent destination files.
Prior to this, it used string-based file paths. These proved especially brittle after Apple started moving app folders around in iOS (~ Xcode 6 & iOS 8).
During the upgrade process (performed when the extension is registered), the migration block can be used to convert previous filePaths to NSURL’s.
Only one of the parameters will be non-nil.
Declaration
Objective-C
typedef NSURL *_Nullable (^YapDatabaseRelationshipMigration)( NSString *_Nullable, NSData *_Nullable)
Swift
typealias YapDatabaseRelationshipMigration = (String?, Data?) -> URL?
Parameters
filePath
The original filePath that was given to the relationship extension
data
The encrypted filePath, generated from a previously configured filePathEncryption block.
-
Undocumented
Declaration
Objective-C
typedef id YapDatabaseSecondaryIndexBlock
Swift
typealias YapDatabaseSecondaryIndexBlock = AnyObject
-
Undocumented
Declaration
Objective-C
typedef void (^YapDatabaseSecondaryIndexWithKeyBlock) (YapDatabaseReadTransaction *transaction, NSMutableDictionary *dict, NSString *collection, NSString *key)
Swift
typealias YapDatabaseSecondaryIndexWithKeyBlock = (YapDatabaseReadTransaction, NSMutableDictionary, String, String) -> Void
-
Undocumented
Declaration
Objective-C
typedef void (^YapDatabaseSecondaryIndexWithObjectBlock) (YapDatabaseReadTransaction *transaction, NSMutableDictionary *dict, NSString *collection, NSString *key, id object)
Swift
typealias YapDatabaseSecondaryIndexWithObjectBlock = (YapDatabaseReadTransaction, NSMutableDictionary, String, String, Any) -> Void
-
Undocumented
Declaration
Objective-C
typedef void (^YapDatabaseSecondaryIndexWithMetadataBlock) (YapDatabaseReadTransaction *transaction, NSMutableDictionary *dict, NSString *collection, NSString *key, __nullable id metadata)
Swift
typealias YapDatabaseSecondaryIndexWithMetadataBlock = (YapDatabaseReadTransaction, NSMutableDictionary, String, String, Any?) -> Void
-
Undocumented
Declaration
Objective-C
typedef void (^YapDatabaseSecondaryIndexWithRowBlock) (YapDatabaseReadTransaction *transaction, NSMutableDictionary *dict, NSString *collection, NSString *key, id object, __nullable id metadata)
Swift
typealias YapDatabaseSecondaryIndexWithRowBlock = (YapDatabaseReadTransaction, NSMutableDictionary, String, String, Any, Any?) -> Void
-
Undocumented
Declaration
Objective-C
typedef struct YapDatabaseViewRangePosition YapDatabaseViewRangePosition
-
Undocumented
Declaration
Objective-C
typedef BOOL (^YapDatabaseViewMappingGroupFilter)(NSString *group, YapDatabaseReadTransaction *transaction)
Swift
typealias YapDatabaseViewMappingGroupFilter = (String, YapDatabaseReadTransaction) -> Bool
-
Undocumented
Declaration
Objective-C
typedef NSComparisonResult (^YapDatabaseViewMappingGroupSort)(NSString *group1, NSString *group2, YapDatabaseReadTransaction *transaction)
Swift
typealias YapDatabaseViewMappingGroupSort = (String, String, YapDatabaseReadTransaction) -> ComparisonResult
-
Undocumented
Declaration
Objective-C
typedef struct YapBidirectionalCacheCallBacks YapBidirectionalCacheCallBacks
-
Undocumented
Declaration
Objective-C
typedef BOOL (^YapWhitelistBlacklistFilterBlock)(id item)
Swift
typealias YapWhitelistBlacklistFilterBlock = (Any) -> Bool
-
How does YapDatabase store my objects to disk?
That question is answered extensively in the wiki article
Storing Objects
: https://github.com/yapstudios/YapDatabase/wiki/Storing-ObjectsHere’s the intro from the wiki article:
In order to store an object to disk (via YapDatabase or any other protocol) you need some way of serializing the object. That is, convert the object into a big blob of bytes. And then, to get your object back from the disk you deserialize it (convert big blob of bytes back into object form).
With YapDatabase, you can choose your preferred serialization/deserialization process.
In order to support adding objects to the database, serializers and deserializers are used. The serializer and deserializer are just simple blocks that you can optionally configure.
The default serializer/deserializer uses NSCoding. This is suitable for Objective-C, but not for Swift.
For Swift: It’s likely you’ll prefer to use the Codable protocol. To do so, you simply register your Codable class for the corresponding collection:
database.registerCodableSerialization(String.self, forCollection: "foo") database.registerCodableSerialization(MyCodableClass.self, forCollection: "bar")
For Objective-C: The default serializer & deserializer use NSCoding (NSKeyedArchiver & NSKeyedUnarchiver). Most of Apple’s primary data types support NSCoding out of the box. And it’s easy to add NSCoding support to your own custom objects.
defaultSerializer = ^(NSString *collection, NSString *key, id object){ return [NSKeyedArchiver archivedDataWithRootObject:object]; }; defaultDeserializer = ^(NSString *collection, NSString *key, NSData *data) { return [NSKeyedUnarchiver unarchiveObjectWithData:data]; };
Declaration
Objective-C
typedef NSData *_Nonnull (^YapDatabaseSerializer)(NSString *_Nonnull, NSString *_Nonnull, id _Nonnull)
Swift
typealias YapDatabaseSerializer = (String, String, Any) -> Data
-
How does YapDatabase store my objects to disk?
That question is answered extensively in the wiki article
Storing Objects
: https://github.com/yapstudios/YapDatabase/wiki/Storing-ObjectsHere’s the intro from the wiki article:
In order to store an object to disk (via YapDatabase or any other protocol) you need some way of serializing the object. That is, convert the object into a big blob of bytes. And then, to get your object back from the disk you deserialize it (convert big blob of bytes back into object form).
With YapDatabase, you can choose your preferred serialization/deserialization process.
In order to support adding objects to the database, serializers and deserializers are used. The serializer and deserializer are just simple blocks that you can optionally configure.
The default serializer/deserializer uses NSCoding. This is suitable for Objective-C, but not for Swift.
For Swift: It’s likely you’ll prefer to use the Codable protocol. To do so, you simply register your Codable class for the corresponding collection:
database.registerCodableSerialization(String.self, forCollection: "foo") database.registerCodableSerialization(MyCodableClass.self, forCollection: "bar")
For Objective-C: The default serializer & deserializer use NSCoding (NSKeyedArchiver & NSKeyedUnarchiver). Most of Apple’s primary data types support NSCoding out of the box. And it’s easy to add NSCoding support to your own custom objects.
defaultSerializer = ^(NSString *collection, NSString *key, id object){ return [NSKeyedArchiver archivedDataWithRootObject:object]; }; defaultDeserializer = ^(NSString *collection, NSString *key, NSData *data) { return [NSKeyedUnarchiver unarchiveObjectWithData:data]; };
Declaration
Objective-C
typedef id _Nullable (^YapDatabaseDeserializer)(NSString *_Nonnull, NSString *_Nonnull, NSData *_Nonnull)
Swift
typealias YapDatabaseDeserializer = (String, String, Data) -> Any?
-
The sanitizer block allows you to enforce desired behavior of the objects you put into the database.
If set, the sanitizer block will be run on all items being input into the database via the setObject:forKey:inCollection: (and other setObject:XXX: methods).
You have 2 different hooks for running a sanitizer block:
The PreSanitizer is run:
- Before the object is serialized
- Before the object is stored in the cache
- Before the object is passed to extensions
The PostSanitizer is run:
- After the object has been serialized
- After the object has been stored in the cache
- After the object has been passed to extensions
The PreSanitizer is generally used validate the objects going into the database, and/or to enforce immutability of those objects.
Enforcing immutability is a topic covered in the
Object Policy
wiki article: https://github.com/yapstudios/YapDatabase/wiki/Object-PolicyThe PostSanitizer is generally used to
clear flags
that are used by extensions. For example, your objects might have achangedProperties
property that tells extensions exactly what properties where changed on a modified object. And the extension uses that information in order to automatically sync the changes to the cloud. Thus the PostSanitizer would be used to clear thechangedProperties
after the extension has processed the modified object.An example of such a use for the PostSanitizer is discussed in the YapDatabaseCloudKit wiki article: https://github.com/yapstudios/YapDatabase/wiki/YapDatabaseCloudKit
Declaration
Objective-C
typedef id _Nonnull (^YapDatabasePreSanitizer)(NSString *_Nonnull, NSString *_Nonnull, id _Nonnull)
Swift
typealias YapDatabasePreSanitizer = (String, String, Any) -> Any
-
The sanitizer block allows you to enforce desired behavior of the objects you put into the database.
If set, the sanitizer block will be run on all items being input into the database via the
setObject:forKey:inCollection:
(and other setObject:XXX: methods).You have 2 different hooks for running a sanitizer block:
The PreSanitizer is run:
- Before the object is serialized
- Before the object is stored in the cache
- Before the object is passed to extensions
The PostSanitizer is run:
- After the object has been serialized
- After the object has been stored in the cache
- After the object has been passed to extensions
The PreSanitizer is generally used validate the objects going into the database, and/or to enforce immutability of those objects.
Enforcing immutability is a topic covered in the
Object Policy
wiki article: https://github.com/yapstudios/YapDatabase/wiki/Object-PolicyThe PostSanitizer is generally used to
clear flags
that are used by extensions. For example, your objects might have achangedProperties
property that tells extensions exactly what properties where changed on a modified object. And the extension uses that information in order to automatically sync the changes to the cloud. Thus the PostSanitizer would be used to clear thechangedProperties
after the extension has processed the modified object.An example of such a use for the PostSanitizer is discussed in the YapDatabaseCloudKit wiki article: https://github.com/yapstudios/YapDatabase/wiki/YapDatabaseCloudKit
Declaration
Objective-C
typedef void (^YapDatabasePostSanitizer)(NSString *_Nonnull, NSString *_Nonnull, id _Nonnull)
Swift
typealias YapDatabasePostSanitizer = (String, String, Any) -> Void