public static string DescriptionForValue(this HMCharacteristic self, int value)
        {
            if (self.IsBoolean())
            {
                return(Convert.ToBoolean(value) ? "On" : "Off");
            }

            var predeterminedValueString = self.PredeterminedValueDescriptionForNumber(value);

            if (predeterminedValueString != null)
            {
                return(predeterminedValueString);
            }

            var metadata = self.Metadata;

            if (metadata != null)
            {
                var stepValue = metadata.StepValue;
                if (stepValue != null)
                {
                    formatter.MaximumFractionDigits = (int)Math.Log10(1f / stepValue.DoubleValue);
                    var str = formatter.StringFromNumber(value);
                    if (!string.IsNullOrEmpty(str))
                    {
                        return(str + self.LocalizedUnitDescription());
                    }
                }
            }

            return(value.ToString());
        }
        // Generates a characteristic cell based on the type of characteristic located at the specified index path.
        UITableViewCell GetCellForCharacteristicCell(UITableView tableView, NSIndexPath indexPath)
        {
            HMCharacteristic characteristic = Service.Characteristics [indexPath.Row];

            var reuseIdentifier = characteristicCell;

            if ((characteristic.IsReadOnly() || characteristic.IsWriteOnly()) && !allowsAllWrites)
            {
                reuseIdentifier = characteristicCell;
            }
            else if (characteristic.IsBoolean())
            {
                reuseIdentifier = switchCharacteristicCell;
            }
            else if (characteristic.HasPredeterminedValueDescriptions())
            {
                reuseIdentifier = segmentedControlCharacteristicCell;
            }
            else if (characteristic.IsNumeric())
            {
                reuseIdentifier = sliderCharacteristicCell;
            }
            else if (characteristic.IsTextWritable())
            {
                reuseIdentifier = textCharacteristicCell;
            }

            var cell = (CharacteristicCell)tableView.DequeueReusableCell(reuseIdentifier, indexPath);

            cell.ShowsFavorites = showsFavorites;
            cell.Delegate       = Delegate;
            cell.Characteristic = characteristic;

            return(cell);
        }