Skip to content
This repository has been archived by the owner on Oct 25, 2022. It is now read-only.

CupByteCountTransformer

aparajita edited this page May 10, 2013 · 2 revisions

This class is a CPValueTransformer that converts numbers into formatted byte counts by using a CPByteCountFormatter. For information on how byte counts are formatted, see the Apple documentation.

By default this class uses a shared formatter with the following properties:

  • adaptive: YES
  • allowedUnits: CPByteCountFormatterUseKB | CPByteCountFormatterUseMB | CPByteCountFormatterUseGB
  • allowsNonNumericFormatting: NO
  • zeroPadsFractionDigits: YES

If you want to change the properties of the shared formatter, you can retrieve it with the +sharedFormatter method.

If you want to change the properties of the formatter for a specific transformer instance, you can either create a new CPByteCountFormatter yourself and use the -setFormatter: method, or use the -formatter method, which will return a new instance of CPByteCountFormatter that belongs to the transformer instance. You can then set the properties of the returned formatter as you wish.

Methods

- (CPByteCountFormatter)formatter

Returns the receiver's instance of CPByteCountFormatter. If the receiver does not yet have its own formatter, a new CPByteCountFormatter is assigned and then returned.

- (void)setFormatter:(CPByteCountFormatter)aFormatter

Sets the formatter used by the receiver. If aFormatter is nil, the shared formatter will be used when transforming values.

Clone this wiki locally