Jed
Jed

Reputation: 512

iOS 9 - "domainIdentifier" for CSSearchableItem

in the init for a CSSearchableItem, one of the parameters is a "domainIdentifier" which Apple writes in its docs is the item's "associated ID." What is this?

Upvotes: 0

Views: 996

Answers (2)

user3745996
user3745996

Reputation:

The Domain identifier is the group name to be indexed. For example if you index all contacts from app use can use like as follows:

searchableItems=[[CSSearchableItem alloc]initWithUniqueIdentifier:identifier domainIdentifier:@"contacts" attributeSet:attributeSet];

The domain identifier name is used to easily delete all index in that domain like this :

[[CSSearchableIndex defaultSearchableIndex]deleteSearchableItemsWithDomainIdentifiers:@[@"contacts"] completionHandler:^(NSError * __nullable error) {

        if (error!=nil)
        {
            NSLog(@"%@",error.description);
        }
        else
        {
            // Indexes deleted successfully
        }
    }];

Upvotes: 1

L A
L A

Reputation: 976

domainIdentifier is a way to group several searchable items together. You will use it to restore/update/delete groups of items, when needed.

Upvotes: 3

Related Questions