Accessing 64-bit integer properties from QML
Some properties in the ArcGIS Maps SDK are 64-bit integer types. The QML language does not have a 64-bit integer type, but we provide ways to work with these properties in the QML API. There are trade-offs with the properties so it's important to understand the options.
The QML API provides the properties as strings. To focus on one property in particular, let's look at
FeatureTable.numberOfFeatures. In the C++ API, this is a
qint64 value while in the QML API it's a
string property. The QML API also offers
FeatureTable.numberOfFeaturesAsInt which is represented as a numeric
int type. This pattern is used consistently in the QML API.
The string representations of properties can lead to misleading results when used directly in numerical comparisons. For example, the following code may behave in a way you do not expect. Even if numberOfFeatures is
"0", the comparison will fail since it's a string.
// problematic code if (myFeatureTable.numberOfFeatures === 0)
You can use this alternative syntax to avoid this issue.
// safer code if (Number(myFeatureTable.numberOfFeatures) === 0) // or if (myFeatureTable.numberOfFeatures == 0)
You can also use the "AsInt" property:
if (myFeatureTable.numberOfFeaturesAsInt === 0)
The downside of accessing the property as an integer is potential truncation. If the
numberOfFeatures property is sufficiently large then
numberOfFeaturesAsInt could be truncated, returning the wrong value. In the event of a truncation the
errorChanged signal will emit.