Float

Float is a single-precision 4 byte floating-point type with an approximate range of 1.2E-38 to 3.4E+38.

The default value of a Float is 0.0. You can change the default value of the property by assigning a new value in an overridden reset method.

Local properties

Slider UI

Allows a float property to be changed in Appfigurate using a slider between minimum and maximum values.

Swift prototype

@FloatPropertySlider(min, max, icon, description, restart)
var propertyName: Float

You can customize the minimum and maximum images using the icon parameter. If restart is true, then the app will be restarted if the property value changes.

Swift example

import AppfigurateLibrary

@objcMembers class Configuration: APLConfiguration {

    @FloatPropertySlider(min: 60.5, max: 120.41, icon: .volume, description: "Clipping - decibels", restart: false)
    var maxDecibel: Float
    
    override func reset() {
        maxDecibel = 100.0
    }
    ...

Editable UI

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

Swift prototype

@FloatPropertyEdit(min, max, regex, description, restart)
var propertyName: Float

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

Swift example

import AppfigurateLibrary

@objcMembers class Configuration: APLConfiguration {

    @FloatPropertyEdit(min: -2.1, max: 4.1, regex: "", description: "Shot accuracy", restart: false)
    var shotAccuracy: Float
    
    override func reset() {
        shotAccuracy = 3.241
    }
    ...

List UI

Allows a float property to be changed in Appfigurate by allowing the user to select from a predefined list of valid choices.

Swift prototype

@FloatPropertyList(description, restart, values)
var propertyName: Float

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

Swift example

import AppfigurateLibrary

@objcMembers class Configuration: APLConfiguration {

    @FloatPropertyList(description: "Quality rating", restart: true, values: ["Low": 10.0, "Average": 50.0, "Excellent": 95.0])
    var rating: Float
    
    override func reset() {
        rating = 10.0
    }
    ...

Editable List UI

Allows a float 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.

Swift prototype

@FloatPropertyListEdit(min, max, regex, description, restart, values)
var propertyName: Float

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

Swift example

import AppfigurateLibrary

@objcMembers class Configuration: APLConfiguration {

    @FloatPropertyListEdit(min: 0.0, max: 366.0, regex: #"^(0?[0-9]?[0-9]|[1-2][0-9][0-9]|3[0-5][0-9]|36[0-5])?(?:\.\d+)?$"#, description: "Forward server time (days)", restart: false, values: ["7 days": 7.0, "1 month": 30.0, "1 Year": 365.0])
    var forwardServerTime: Float
    
    override func reset() {
        forwardServerTime = 7.0
    }
    ...

Last updated