# Integer

{% tabs %}
{% tab title="Swift" %}
`Int` is platform dependent, 32-bit signed values on 32-bit CPUs (Apple Watch; arm64\_32) and 64-bit signed values on 64-bit CPUs (iPhone, iPad; arm64).

The default value of a `Int` is 0. You can 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" %}
`NSInteger` is platform dependent, 32-bit signed values on 32-bit CPUs (Apple Watch arm64\_32) and 64-bit signed values on 64-bit CPUs (iPhone, iPad arm64).

The default value of a `NSInteger` is 0. You can 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.

`NSInteger` 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, assign) NSInteger 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.

React Native always converts the underlying Integer to a JavaScript Number - you should be aware of [JavaScript's 53 bit limitation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER).
{% endtab %}
{% endtabs %}

## **Local properties**

### **Slider UI**

Allows an integer property to be changed in Appfigurate using a slider between minimum and maximum values.&#x20;

![](https://1008176080-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fw1fcw3dvtSrfUh3YtO9Z%2Fuploads%2FeEyNnpYwUoZMqSCM0NGD%2FIntSlider.png?alt=media\&token=a39ae690-4151-450c-8a0e-c512c66701ff)

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

> Swift prototype

```swift
@IntPropertySlider(min, max, icon, description, restart)
var propertyName: Int
```

You can customize the minimum and maximum images using the [<mark style="color:blue;">`icon`</mark>](https://www.electricbolt.co.nz/api/Enums/APLIconSlider.html) parameter. If `restart` is `true`, then the app will be restarted if the property value changes.

> Swift example

```swift
import AppfigurateLibrary

@objcMembers class Configuration: APLConfiguration {

    @IntPropertySlider(min: 50, max: 100, icon: .volume, description: "Limit volume level", restart: true)
    var volumeRange: Int
    
    override func reset() {
        volumeRange = 75
    }
    ...
```

{% endtab %}

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

> Objective-C prototype

```objectivec
INT_PROPERTY_SLIDER(propertyName, minValue, maxValue, icon, description, restart)
```

You can customize the minimum and maximum images using the [<mark style="color:blue;">`icon`</mark>](https://docs.electricbolt.co.nz/configuration-subclasses/slider-icon-types) parameter. If `restart` is `YES`, then the app will be restarted if the property value changes.

> Objective-C example

```objectivec
@import AppfigurateLibrary;

@interface Configuration : APLConfiguration

@property(nonatomic, assign) NSInteger volumeRange;

@end

@implementation Configuration

INT_PROPERTY_SLIDER(volumeRange, 50, 100, APLIconSliderVolume, @"Limit volume level", NO);

- (void) reset {
    self.volumeRange = 75;
}
...
```

{% endtab %}

{% tab title="Dart" %}

> Dart prototype

```dart
int get propertyName => nativeInt('propertyName');
```

> Dart example

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

public class Configuration extends APLNativeConfiguration {

    int get volumeRange => nativeInt('volumeRange');
    ...
```

{% endtab %}

{% tab title="JavaScript" %}

> JavaScript example

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

const {Appfigurate} = NativeModules;

...

let volumeRange = await Appfigurate.nativeValue("volumeRange"); // Number
```

{% endtab %}
{% endtabs %}

### **Editable UI**

Allows an integer property to be changed in Appfigurate using a text field between minimum and maximum values, and an optional regular expression validating input.

![](https://1008176080-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fw1fcw3dvtSrfUh3YtO9Z%2Fuploads%2FqrQVeSmoXXwxhfsvCfI6%2FIntEdit.png?alt=media\&token=8523f210-24c3-432a-b04f-ea653371a83e)

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

> Swift prototype

```swift
@IntPropertyEdit(min, max, regex, description, restart)
var propertyName: Int
```

If `restart` is `true`, then the app will be restarted if the property value changes.

> Swift example

```swift
import AppfigurateLibrary

@objcMembers class Configuration: APLConfiguration {

    @IntPropertyEdit(min: 1, max: 5, regex: "", description: "Maximum number of game levels", restart: false)
    var gameLevels: Int
    
    override func reset() {
        gameLevels = 3
    }
    ...
```

{% endtab %}

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

> Objective-C prototype

```objectivec
INT_PROPERTY_EDIT(propertyName, minValue, maxValue, regex, description, restart)
```

If `restart` is `YES`, then the app will be restarted if the property value changes.

> Objective-C example

```objectivec
@import AppfigurateLibrary;

@interface Configuration : APLConfiguration

@property(nonatomic, assign) NSInteger gameLevels;

@end

@implementation Configuration

INT_PROPERTY_EDIT(gameLevels, 1, 5, @"", @"Maximum number of game levels", NO);

- (void) reset {
    self.gameLevels = 3;
}
...
```

{% endtab %}

{% tab title="Dart" %}

> Dart prototype

```dart
int get propertyName => nativeInt('propertyName');
```

> Dart example

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

public class Configuration extends APLNativeConfiguration {

    int get gameLevels => nativeInt('gameLevels');
    ...
```

{% endtab %}

{% tab title="JavaScript" %}

> JavaScript example

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

const {Appfigurate} = NativeModules;

...

let gameLevels = await Appfigurate.nativeValue("gameLevels"); // Number
```

{% endtab %}
{% endtabs %}

### **List UI**

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

![](https://1008176080-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fw1fcw3dvtSrfUh3YtO9Z%2Fuploads%2FrrqMnRNs6TmtntQk9v9d%2FIntList.png?alt=media\&token=b5170ccc-b869-4cfd-a076-a731d0c39417)

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

> Swift prototype

<pre class="language-swift"><code class="lang-swift"><strong>@IntPropertyList(description, restart, values)
</strong>var propertyName: Int
</code></pre>

If `restart` is `true`, then the app will be restarted if the property value changes.

> Swift example

```swift
import AppfigurateLibrary

@objcMembers class Configuration: APLConfiguration {

    @IntPropertyList(description: "Quality rating", restart: false, values: ["Low": 10, "Average": 50, "Excellent": 95])
    var rating: Int
    
    override func reset() {
        rating = 10
    }
    ...
```

{% endtab %}

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

> Objective-C prototype

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

If `restart` is `YES`, then the app will be restarted if the property value changes.

> Objective-C example

```objectivec
@import AppfigurateLibrary;

@interface Configuration : APLConfiguration

@property(nonatomic, assign) NSInteger rating;

@end

@implementation Configuration

INT_PROPERTY_LIST(rating, @"Quality rating", NO, @{@"Low": @10, @"Average": @50, @"Excellent": @95});

- (void) reset {
    self.rating = 10;
}
...
```

{% endtab %}

{% tab title="Dart" %}

> Dart prototype

```dart
int get propertyName => nativeInt('propertyName');
```

> Dart example

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

public class Configuration extends APLNativeConfiguration {

    int get rating => nativeInt('rating');
    ...
```

{% endtab %}

{% tab title="JavaScript" %}

> JavaScript example

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

const {Appfigurate} = NativeModules;

...

let rating = await Appfigurate.nativeValue("rating"); // Number
```

{% endtab %}
{% endtabs %}

### **Editable List UI**

Allows an integer 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 between minimum and maximum values, and an optional regular expression validating input.&#x20;

![](https://1008176080-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fw1fcw3dvtSrfUh3YtO9Z%2Fuploads%2F1Bz6beGhs7OeXosyDukG%2FIntListEdit.png?alt=media\&token=9f666efd-baec-4904-8965-0aedee592eeb)

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

> Swift prototype

```swift
@IntPropertyListEdit(min, max, regex, description, restart, values)
var propertyName: Int
```

If `restart` is `true`, then the app will be restarted if the property value changes.

> Swift example

```swift
import AppfigurateLibrary

@objcMembers class Configuration: APLConfiguration {

    @IntPropertyListEdit(min: 0, max: 365, regex: "^(0?[0-9]?[0-9]|[1-2][0-9][0-9]|3[0-5][0-9]|36[0-5])$", description: "Duration in days emails are available", restart: false, values: ["7 days": 7, "1 month": 30, "1 Year": 365])
    var availablityDuration: Int
    
    override func reset() {
        volumeRange = 7
    }
    ...
```

{% endtab %}

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

> Objective-C prototype

```objectivec
INT_PROPERTY_LIST_EDIT(propertyName, minValue, maxValue, regex, description, restart, ...)
```

If `restart` is `YES`, then the app will be restarted if the property value changes.

> Objective-C example

```objectivec
@import AppfigurateLibrary;

@interface Configuration : APLConfiguration

@property(nonatomic, assign) NSInteger availabilityDuration;

@end

@implementation Configuration

INT_PROPERTY_LIST_EDIT(availablityDuration, 0, 365, @"^(0?[0-9]?[0-9]|[1-2][0-9][0-9]|3[0-5][0-9]|36[0-5])$", @"Duration in days emails are available", NO, @{@"7 days": @7, @"1 month": @30, @"1 Year": @365});

- (void) reset {
    self.volumeRange = 7;
}
...
```

{% endtab %}

{% tab title="Dart" %}

> Dart prototype

```dart
int get propertyName => nativeInt('propertyName');
```

> Dart example

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

public class Configuration extends APLNativeConfiguration {

    int get availabilityDuration => nativeInt('availabilityDuration');
    ...
```

{% endtab %}

{% tab title="JavaScript" %}

> JavaScript example

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

const {Appfigurate} = NativeModules;

...

let availabilityDuration = await Appfigurate.nativeValue("availabilityDuration"); // Number
```

{% endtab %}
{% endtabs %}

## Remote properties

### Remote Editable UI

Allows a third party remote configuration provider's integer 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;![](https://1008176080-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fw1fcw3dvtSrfUh3YtO9Z%2Fuploads%2FlSbSWb1o3CxEPJVzq5d4%2Fremoteintedit.png?alt=media\&token=0329d46d-e26f-410c-9eb8-2883f3ca7c5c)

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

> Swift prototype

```swift
@RemoteIntPropertyEdit(remoteKey, description)
var propertyName: Int
```

> Swift example

```swift
import AppfigurateLibrary

@objcMembers class Configuration: APLConfiguration {
    
    @RemoteIntPropertyEdit(remoteKey: "bookingDuration", description: "Duration (days) for reservation bookings")
    var bookingDuration: Int
    
    override func reset() {
        bookingDuration = 180
    }
    ...
```

{% endtab %}

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

> Objective-C prototype

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

> Objective-C example

```objectivec
@import AppfigurateLibrary;

@interface Configuration : APLConfiguration

@property(nonatomic, assign) NSInteger bookingDuration;

@end

@implementation Configuration

REMOTE_INT_PROPERTY_EDIT(bookingDuration, @"bookingDuration", @"Duration (days) for reservation bookings");

- (void) reset {
    self.bookingDuration = 180;
}
...
```

{% endtab %}

{% tab title="Dart" %}

> Dart prototype

```dart
int get propertyName => nativeInt('propertyName');
```

> Dart example

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

public class Configuration extends APLNativeConfiguration {

    int get bookingDuration => nativeInt('bookingDuration');
    ...
```

{% endtab %}

{% tab title="JavaScript" %}

> JavaScript example

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

const {Appfigurate} = NativeModules;

...

let bookingDuration = await Appfigurate.nativeValue("bookingDuration"); // Number
```

{% endtab %}
{% endtabs %}
