# Plain String

{% tabs %}
{% tab title="Swift" %}
The default value of a `String` is "". You **must** change the default value of the property by assigning a new value in an overridden [<mark style="color:blue;">`reset`</mark>](https://www.electricbolt.co.nz/api/Classes/APLConfiguration.html#/c:objc\(cs\)APLConfiguration\(im\)reset) method.
{% endtab %}

{% tab title="Objective-C" %}
The default value of a `NSString` is @"". You **must** change the default value of the property by assigning a new value in an overridden [<mark style="color:blue;">`reset`</mark>](https://www.electricbolt.co.nz/api/Classes/APLConfiguration.html#/c:objc\(cs\)APLConfiguration\(im\)reset) method.&#x20;

`NSString` properties should be declared in your [<mark style="color:blue;">`APLConfiguration`</mark>](https://www.electricbolt.co.nz/api/Classes/APLConfiguration.html) subclass header file as follows:

```objectivec
@import AppfigurateLibrary;

@interface Configuration : APLConfiguration

@property(nonatomic, strong) NSString* propertyName;
...
```

{% endtab %}

{% tab title="Dart" %}
The flutter [<mark style="color:blue;">`APLNativeConfiguration`</mark>](https://pub.dev/documentation/appfigurateflutter/latest/appfigurateflutter/APLNativeConfiguration-class.html) class defers to the underlying platform [<mark style="color:blue;">`APLConfiguration`</mark>](https://www.electricbolt.co.nz/api/Classes/APLConfiguration.html) (iOS) or [<mark style="color:blue;">`nz.co.electricbolt.appfiguratelibrary.Configuration`</mark>](https://www.electricbolt.co.nz/api/android/nz/co/electricbolt/appfiguratelibrary/Configuration.html) (Android) subclass to read property values.
{% endtab %}

{% tab title="JavaScript" %}
The React Native module `AppfigurateModule` class defers to the underlying platform [<mark style="color:blue;">`APLConfiguration`</mark>](https://www.electricbolt.co.nz/api/Classes/APLConfiguration.html) (iOS) or [<mark style="color:blue;">`nz.co.electricbolt.appfiguratelibrary.Configuration`</mark>](https://www.electricbolt.co.nz/api/android/nz/co/electricbolt/appfiguratelibrary/Configuration.html) (Android) subclass to read property values.
{% endtab %}
{% endtabs %}

This page describes plain textual strings. Appfigurate also supports [encrypted strings](/configuration-subclasses/supported-property-types/encrypted-string.md).

## **Local properties**

### **Editable UI**

Allows a string property to be changed in Appfigurate using a text field with an optional regular expression validating input.

![](/files/jcYuX6OlRVqfEMdCzIIj)

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

> Swift prototype

<pre class="language-swift"><code class="lang-swift">@StringPropertyEdit(regex, description, restart)
var propertyName: <a data-footnote-ref href="#user-content-fn-1">String</a>
</code></pre>

> Swift example

<pre class="language-swift"><code class="lang-swift">import AppfigurateLibrary

@objcMembers class Configuration: APLConfiguration {

    @StringPropertyEdit(regex: "", description: "Overridden session username", restart: false)
    var usernameOverride: <a data-footnote-ref href="#user-content-fn-1">String</a>
    
    override func reset() {
        usernameOverride = "thomas52"
    }
    ...
</code></pre>

{% endtab %}

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

> Objective-C prototype

```objectivec
STRING_PROPERTY_EDIT(propertyName, regex, description, restart)
```

> Objective-C example

```objectivec
@import AppfigurateLibrary;

@interface Configuration : APLConfiguration

@property(nonatomic, strong) NSString* usernameOverride;

@end

@implementation Configuration

STRING_PROPERTY_EDIT(usernameOverride, @"", @"Overridden session username", NO);

- (void) reset {
    self.usernameOverride = @"thomas52";
}
...
```

{% endtab %}

{% tab title="Dart" %}

> Dart prototype

```dart
String get propertyName => nativeString('propertyName');
```

> Dart example

```dart
import 'package:appfigurateflutter/appfigurateflutter.dart';

public class Configuration extends APLNativeConfiguration {

    String get usernameOverride => nativeString('usernameOverride');
    ...
```

{% endtab %}

{% tab title="JavaScript" %}

> JavaScript example

```javascript
import {
  NativeModules,
} from 'react-native';

const {Appfigurate} = NativeModules;

...

let usernameOverride = await Appfigurate.nativeValue("usernameOverride");
```

{% endtab %}
{% endtabs %}

### **List UI**

Allows a string property to be changed in Appfigurate by allowing the user to select from a predefined list of valid choices.&#x20;

![](/files/rlqxD0hHOhhkJUw2zkBG)

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

> Swift prototype

<pre class="language-swift"><code class="lang-swift">@StringPropertyList(description, restart, values)
var propertyName: <a data-footnote-ref href="#user-content-fn-1">String</a>
</code></pre>

> Swift example

<pre class="language-swift"><code class="lang-swift">import AppfigurateLibrary

@objcMembers class Configuration: APLConfiguration {

    @StringPropertyList(description: "Color of background", restart: false, values: ["LightGray":"#d3d3d3", "White":"#ffffff", "Beige":"f5fcdc"])
    var backgroundColorHex: <a data-footnote-ref href="#user-content-fn-1">String</a>
    
    override func reset() {
        backgroundColorHex = "#d3d3de"
    }
    ...
</code></pre>

{% endtab %}

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

> Objective-C prototype

```objectivec
STRING_PROPERTY_LIST(propertyName, description, restart, ...)
```

> Objective-C example

```objectivec
@import AppfigurateLibrary;

@interface Configuration : APLConfiguration

@property(nonatomic, strong) NSString* backgroundColorHex;

@end

@implementation Configuration

STRING_PROPERTY_LIST(backgroundColorHex, @"Color of background", NO, @{@"LightGray": @"#d3d3d3", @"White": @"#ffffff", @"Beige": @"f5fcdc"});

- (void) reset {
    self.backgroundColorHex = "#d3d3d3";
}
...
```

{% endtab %}

{% tab title="Dart" %}

> Dart prototype

```dart
String get propertyName => nativeString('propertyName');
```

> Dart example

```dart
import 'package:appfigurateflutter/appfigurateflutter.dart';

public class Configuration extends APLNativeConfiguration {

    String get backgroundColorHex => nativeString('backgroundColorHex');
    ...
```

{% endtab %}

{% tab title="JavaScript" %}

> JavaScript example

```javascript
import {
  NativeModules,
} from 'react-native';

const {Appfigurate} = NativeModules;

...

let backgroundColorHex = await Appfigurate.nativeValue("backgroundColorHex");
```

{% endtab %}
{% endtabs %}

### **Editable List UI**

Allows a string property to be changed in Appfigurate by allowing the user to select from a predefined list of valid choices. The user can customize the list adding by additional values using a text field and an optional regular expression validating input.&#x20;

![](/files/CLM2mWvQmhzApP0xRdHS)

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

> Swift prototype

<pre class="language-swift"><code class="lang-swift">@StringPropertyListEdit(regex, description, restart, values)
var propertyName: <a data-footnote-ref href="#user-content-fn-1">String</a>
</code></pre>

> Swift example

<pre class="language-swift"><code class="lang-swift">import AppfigurateLibrary

@objcMembers class Configuration: APLConfiguration {

    @StringPropertyListEdit(regex: "^#([a-f0-9]{6})$", description: "Color of foreground", restart: false, values: ["Black":"#000000", "MistyRose":"#ffe4e1", "LightBlue":"add8e6"])
    var foregroundColorHex: <a data-footnote-ref href="#user-content-fn-1">String</a>
    
    override func reset() {
        foregroundColorHex = "#ffe4e1"
    }
    ...
</code></pre>

{% endtab %}

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

> Objective-C prototype

```objectivec
STRING_PROPERTY_LIST_EDIT(propertyName, regex, description, restart, ...)
```

> Objective-C example

```objectivec
@import AppfigurateLibrary;

@interface Configuration : APLConfiguration

@property(nonatomic, strong) NSString* foregroundColorHex;

@end

@implementation Configuration

STRING_PROPERTY_LIST_EDIT(foregroundColorHex, @"^#([a-f0-9]{6})$", @"Color of foreground", NO, @{@"Black": @"#000000", @"MistyRose": @"#ffe4e1", @"LightBlue": @"add8e6"});

- (void) reset {
    self.foregroundColorHex = @"#ffe4e1";
}
...
```

{% endtab %}

{% tab title="Dart" %}

> Dart prototype

```dart
String get propertyName => nativeString('propertyName');
```

> Dart example

```dart
import 'package:appfigurateflutter/appfigurateflutter.dart';

public class Configuration extends APLNativeConfiguration {

    String get foregroundColorHex => nativeString('foregroundColorHex');
    ...
```

{% endtab %}

{% tab title="JavaScript" %}

> JavaScript example

```javascript
import {
  NativeModules,
} from 'react-native';

const {Appfigurate} = NativeModules;

...

let foregroundColorHex = await Appfigurate.nativeValue("foregroundColorHex");
```

{% endtab %}
{% endtabs %}

## **Remote properties**

### **Remote Editable UI**

Allows a third party remote configuration provider's string property to be changed locally in Appfigurate using a text field. If the override tick box is ticked off, the third party remote configuration provider's value is displayed. If the override tick box is ticked on, then you can use Appfigurate to locally override the value.

&#x20;![](/files/D7ThCqru5Z40LGq4B6Fm)&#x20;

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

> Swift prototype

```swift
@RemoteStringPropertyEdit(remoteKey, description, restart)
var propertyName: String
```

> Swift example

```swift
import AppfigurateLibrary

@objcMembers class Configuration: APLConfiguration {

    @RemoteStringPropertyEdit(remoteKey: "appTitle", description: "Title of application")
    var appTitle: String
    
    override func reset() {
        appTitle = "Holiday finder"
    }
    ...
```

{% endtab %}

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

> Objective-C prototype

<pre class="language-objectivec"><code class="lang-objectivec"><strong>REMOTE_STRING_PROPERTY_EDIT(propertyName, remoteKey, description)
</strong></code></pre>

> Objective-C example

```objectivec
@import AppfigurateLibrary;

@interface Configuration : APLConfiguration

@property(nonatomic, assign) String appTitle;

@end

@implementation Configuration

REMOTE_STRING_PROPERTY_EDIT(appTitle, @"Title of application");

- (void) reset {
    self.appTitle = @"Holiday finder";
}
...
```

{% endtab %}

{% tab title="Dart" %}

> Dart prototype

```dart
String get propertyName => nativeString('propertyName');
```

> Dart example

```dart
import 'package:appfigurateflutter/appfigurateflutter.dart';

public class Configuration extends APLNativeConfiguration {

    String get appTitle => nativeString('appTitle');
    ...
```

{% endtab %}

{% tab title="JavaScript" %}

> JavaScript example

```javascript
import {
  NativeModules,
} from 'react-native';

const {Appfigurate} = NativeModules;

...

let appTitle = await Appfigurate.nativeValue("appTitle");
```

{% endtab %}
{% endtabs %}

[^1]: You should leave this as String, and not String! or String?. Any value assigned to this instance variable will be ignored, instead set the default value in the reset method.


---

# 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://docs.electricbolt.co.nz/configuration-subclasses/supported-property-types/plain-string.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.
