-
Notifications
You must be signed in to change notification settings - Fork 1
/
CoreSpotlight+Convenience.m
89 lines (70 loc) · 2.58 KB
/
CoreSpotlight+Convenience.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//
// CoreSpotlight+Convenience.m
// Ringtonic
//
// Created by Alexander Ivanov on 15.11.16.
// Copyright © 2016 Alexander Ivanov. All rights reserved.
//
#import "CoreSpotlight+Convenience.h"
@implementation CSSearchableIndex (Convenience)
- (void)indexSearchableItems:(NSArray<CSSearchableItem *> *)items {
if (!items.count)
return;
[self indexSearchableItems:items completionHandler:^(NSError * _Nullable error) {
[error log:@"indexSearchableItems:"];
}];
}
- (void)indexSearchableItem:(CSSearchableItem *)item {
[self indexSearchableItems:arr_(item)];
}
- (void)deleteSearchableItemsWithIdentifiers:(NSArray<NSString *> *)identifiers {
if (!identifiers.count)
return;
[self deleteSearchableItemsWithIdentifiers:identifiers completionHandler:^(NSError * _Nullable error) {
[error log:@"deleteSearchableItemsWithIdentifiers:"];
}];
}
- (void)deleteSearchableItemsWithIdentifier:(NSString *)identifier {
[self deleteSearchableItemsWithIdentifiers:arr_(identifier)];
}
- (void)deleteSearchableItemsWithDomainIdentifiers:(NSArray<NSString *> *)domainIdentifiers {
if (!domainIdentifiers.count)
return;
[self deleteSearchableItemsWithDomainIdentifiers:domainIdentifiers completionHandler:^(NSError * _Nullable error) {
[error log:@"deleteSearchableItemsWithDomainIdentifiers:"];
}];
}
- (void)deleteSearchableItemsWithDomainIdentifier:(NSString *)domainIdentifier {
[self deleteSearchableItemsWithDomainIdentifiers:arr_(domainIdentifier)];
}
- (void)deleteAllSearchableItems {
[self deleteAllSearchableItemsWithCompletionHandler:^(NSError * _Nullable error) {
[error log:@"deleteAllSearchableItemsWithCompletionHandler:"];
}];
}
- (void)reindexSearchableItems:(NSArray<CSSearchableItem *> *)items {
if (!items.count)
return;
[self deleteSearchableItemsWithIdentifiers:[items map:^id(CSSearchableItem *obj) {
return obj.uniqueIdentifier;
}] completionHandler:^(NSError * _Nullable error) {
[error log:@"deleteSearchableItemsWithIdentifiers:"];
[self indexSearchableItems:items completionHandler:^(NSError * _Nullable error) {
[error log:@"indexSearchableItems:"];
}];
}];
}
- (void)reindexSearchableItem:(CSSearchableItem *)item {
[self reindexSearchableItems:arr_(item)];
}
- (void)reindexAllSearchableItems:(NSArray<CSSearchableItem *> *)items {
if (!items.count)
return;
[self deleteAllSearchableItemsWithCompletionHandler:^(NSError * _Nullable error) {
[error log:@"deleteAllSearchableItemsWithCompletionHandler:"];
[self indexSearchableItems:items completionHandler:^(NSError * _Nullable error) {
[error log:@"indexSearchableItems:"];
}];
}];
}
@end