// 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); }
// Returns the description for a provided value, taking the characteristic's metadata and possible values into account. public static string DescriptionForValue(this HMCharacteristic self, NSObject value) { if (self.IsWriteOnly()) { return("Write-Only Characteristic"); } var number = value as NSNumber; return(number != null?self.DescriptionForValue(number.Int32Value) : value.ToString()); }
public static string LocalizedCharacteristicType(this HMCharacteristic self) { var type = self.LocalizedDescription; string description = null; if (self.IsReadOnly()) { description = "Read Only"; } else if (self.IsWriteOnly()) { description = "Write Only"; } if (description != null) { type = string.Format("{0} {1}", type, description); } return(type); }