Class: NSByteCountFormatter
- Inherits:
-
NSFormatter
- Object
- NSObject
- NSFormatter
- NSByteCountFormatter
Overview
The NSByteCountFormatter class converts a byte count value into a textual representation that is formatted with the appropriate byte modifier (KB, MB, GB and so on).
Instance Attribute Summary (collapse)
-
- adaptive
Determines the display style of the size representation.
-
- allowedUnits
Specify the units that can be used in the output.
-
- allowsNonnumericFormatting
Determines whether to allow more natural display of some values.
-
- countStyle
Specify the the number of bytes to be used for kilobytes.
-
- includesActualByteCount
Determines whether to include the number of bytes after the formatted string.
-
- includesCount
Determines whether to include the count in the resulting formatted string.
-
- includesUnit
Determines whether to include the units in the resulting formatted string.
-
- zeroPadsFractionDigits
Determines whether to zero pad fraction digits so a consistent number of characters is displayed in a representation.
Class Method Summary (collapse)
-
+ stringFromByteCount:countStyle:
Converts a byte count into the specified string format without creating an NSNumber object.
Instance Method Summary (collapse)
-
- stringFromByteCount:
Converts a byte count into a string without creating an NSNumber object.
Methods inherited from NSFormatter
#attributedStringForObjectValue:withDefaultAttributes:, #editingStringForObjectValue:, #getObjectValue:forString:errorDescription:, #isPartialStringValid:newEditingString:errorDescription:, #isPartialStringValid:proposedSelectedRange:originalString:originalSelectedRange:errorDescription:, #stringForObjectValue:
Methods inherited from NSObject
#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version
Constructor Details
This class inherits a constructor from NSObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class NSObject
Instance Attribute Details
- (Boolean) adaptive
Determines the display style of the size representation. The "adaptive" algorithm is platform specific and uses a different number of fraction digits based on the magnitude (on OS X v10.8: 0 fraction digits for bytes and KB; 1 fraction digits for MB; 2 for GB and above). Otherwise the result always tries to show at least three significant digits, introducing fraction digits as necessary. Default is YES.
- (NSByteCountFormatterUnits) allowedUnits
Specify the units that can be used in the output. If the value is NSByteCountFormatterUseDefault, the formatter uses platform-appropriate settings; otherwise will only the specified units are used.“NSByteCountFormatterUnits” values can be combined using the C OR operator to specify complex formatting strings. The NSByteCountFormatterUseDefault or NSByteCountFormatterUseAll constants can be used with the C AND or the C NOT operators to create custom formats as well.This is the default value if NSByteCountFormatterUseDefault. Note: ZB and YB cannot be covered by the range of possible values, but you can still choose to use these units to get fractional display (“0.0035 ZB” for instance).
- (Boolean) allowsNonnumericFormatting
Determines whether to allow more natural display of some values. Displays a more natural display of some values, such as zero, where it may be displayed as "Zero KB," ignoring all other flags or options (with the exception of NSByteCountFormatterUseBytes, which would generate "Zero bytes").The result is appropriate for standalone output. Special handling of certain values such as zero is especially important in some languages, so it's highly recommended that this property be left in its default state.Default value is YES.
- (NSByteCountFormatterCountStyle) countStyle
Specify the the number of bytes to be used for kilobytes. The default setting is NSByteCountFormatterCountStyleFile, which is the system specific value for file and storage sizes.
- (Boolean) includesActualByteCount
Determines whether to include the number of bytes after the formatted string. Setting this value to YES causes the byte count to be displayed parenthetically (localized as appropriate), for instance "723 KB (722,842 bytes)". This will happen only if needed, that is, the first part is already not showing the exact byte count. If includesUnit or includesCount are NO, then this setting has no effect.Default value is NO.
- (Boolean) includesCount
Determines whether to include the count in the resulting formatted string. If set to YES and includesUnit is set to NO, instead of 723 KB, returns “723”.You can get the set this property to YES and the includesUnit to YES individually to get both parts, separately. Note that putting them together yourself via string concatenation may be wrong for some locales.The default value is YES.Note: Setting this value to NO and allowedUnits to NO results in an empty string.
- (Boolean) includesUnit
Determines whether to include the units in the resulting formatted string. If set to YES and includesCount is set to NO, instead of 723 KB, returns “KB”.You can get the set this property to YES and the includesCount to YES individually to get both parts, separately. Note that putting them together yourself via string concatenation may be wrong for some locales.The default value is YES.Note: Setting this value to NO and includesCount to NO results in an empty string.
- (Boolean) zeroPadsFractionDigits
Determines whether to zero pad fraction digits so a consistent number of characters is displayed in a representation. Displaying values using zero pad fraction digits causes a consistent number of fraction digits are displayed, causing updating displays to remain more stable. For instance, if the adaptive algorithm is used, this option formats 1.19 and 1.2 GB as "1.19 GB" and "1.20 GB" respectively, while without the option the latter would be displayed as "1.2 GB". Default value is NO.