Skip to content

Commit 05e4496

Browse files
committed
fix: setSettingsThenSaveObjects
1 parent 12dda74 commit 05e4496

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

templates/swift/guides/search/setSettingsThenSaveObjects.mustache

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,22 @@ import Core
77
{{> snippets/import}}
88

99
func setSettingsThenSaveObjects() async throws {
10-
do {
11-
{{> snippets/init}}
10+
for playlist in playlists {
11+
// Fetch from your own data storage and with your own code
12+
// the associated application ID and API key for this user
13+
let appID = getAppIDFor(playlist.user);
14+
let apiKey = getIndexingApiKeyFor(playlist.user);
1215
13-
let settings = IndexSettings(
14-
attributesForFaceting: ["filterOnly(user)"]
15-
)
16-
{{#dynamicSnippet}}setSettings{{/dynamicSnippet}}
16+
do {
17+
let client = try SearchClient(appID: appID, apiKey: apiKey)
18+
let settings = IndexSettings(
19+
attributesForFaceting: ["filterOnly(user)"]
20+
)
21+
{{#dynamicSnippet}}setSettings{{/dynamicSnippet}}
1722

18-
{{#dynamicSnippet}}saveObjectsPlaylists{{/dynamicSnippet}}
19-
} catch {
20-
print(error)
23+
{{#dynamicSnippet}}saveObjectsPlaylists{{/dynamicSnippet}}
24+
} catch {
25+
print(error)
26+
}
2127
}
2228
}

0 commit comments

Comments
 (0)