# Topic preferences

The Batch iOS SDK allows you to:

* Add or remove topic preferences from a user profile (the profile is created automatically if it doesn’t already exist).
* Partially update topic preferences within a user profile.

> Requires SDK 3.3+

Here’s how to update topic preferences:

{% tabs %}
{% tab title="Swift" %}

```swift
BatchProfile.editor { editor in
    try? editor.setTopicPreferences(["technology", "finance"]) // Null to erase
    // Alternatively, partially update them with:
    try? editor.addToTopicPreferences(["investing"])
    try? editor.removeFromTopicPreferences(["travel"])
    // If you prefer to use BatchProfile.editor() with local variable instead of using a closure,
    // remember to use editor.save() afterwards so that the changes are taken into account.
}
```

{% endtab %}

{% tab title="Objective-C" %}

```objectivec
// This requires to have a custom user ID registered by calling the `identify` method beforehand.
[BatchProfile editWithBlock:^(BatchProfileEditor * _Nonnull editor) {
     NSError *error = nil;
     [editor setTopicPreferences:@[@"technology", @"finance"] error:&error];
     // Alternatively, partially update them with:
     [editor addToTopicPreferences:@[@"investing"] error:&error];
     [editor removeFromTopicPreferences:@[@"travel"] error:&error];
     // If you prefer to use [BatchProfile editor] instead of `editWithBlock`,
     // remember to use [editor save] afterwards so that the changes are taken into account.
}];
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Note**: Topics must be a valid List of String not longer than 25 items. String should be made of letters, numbers or underscores (\[a-z0-9\_]) and can't be longer than 300 characters.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.batch.com/developer/sdk/ios/profile-data/topic-preferences.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
