The following code is Swift class that is being used by objective C classes in a mixed project.
It is followed by the corresponding interface in the xxx-Swift.h file.
The method (func) names are changed in the xxx-Swift.h file. I did not expect this at all.
1. Where can I find this documented.
2. When is the xxx-Swift.h file generated an updated
import Foundation
open class DisplayFormatter : NSObject
{
@objc public var mode : UInt
@objc public var precision : UInt
@objc public var useSeperator : Bool
@objc var fieldFormat : String;
override init()
{
mode = 0
precision = 2
useSeperator = false
fieldFormat = String( " ")
}
@objc public func setFormatString (formatStr : String)
{
fieldFormat = formatStr
}
@objc public func getDecimalFormattedString (value : Double) -> String
{
let numberFormatter = NumberFormatter()
if ( fieldFormat.count > 0)
{
numberFormatter.positiveFormat = fieldFormat
numberFormatter.formatterBehavior = .behavior10_4
numberFormatter.numberStyle = .decimal
numberFormatter.minimumFractionDigits = 0
numberFormatter.maximumFractionDigits = Int(precision)
}
if (!useSeperator)
{
numberFormatter.groupingSeparator = ""
}
let n = NSNumber.init(value: value)
let returnString = numberFormatter.string(from: n)
return returnString!;
}
@objc public func getScientificFormattedString (value : Double) -> String
{
let numberFormatter = NumberFormatter()
if ( fieldFormat.count > 0)
{
numberFormatter.positiveFormat = fieldFormat
numberFormatter.formatterBehavior = .behavior10_4
numberFormatter.numberStyle = .scientific
numberFormatter.minimumFractionDigits = 0
numberFormatter.maximumFractionDigits = Int(precision)
}
if (!useSeperator)
{
numberFormatter.groupingSeparator = ""
}
let n = NSNumber.init(value: value)
let returnString = numberFormatter.string(from: n)
return returnString!;
}
@objc public func getCurrencyFormattedString (value : Double) -> String
{
let numberFormatter = NumberFormatter()
if ( fieldFormat.count > 0)
{
numberFormatter.positiveFormat = fieldFormat
numberFormatter.formatterBehavior = .behavior10_4
numberFormatter.numberStyle = .currency
numberFormatter.minimumFractionDigits = 0
numberFormatter.maximumFractionDigits = Int(precision)
}
if (!useSeperator)
{
numberFormatter.groupingSeparator = ""
}
let n = NSNumber.init(value: value)
let returnString = numberFormatter.string(from: n)
return returnString!;
}
@objc public func getFormattedString( value : Double) -> String
{
if (mode == 0)
{
return getDecimalFormattedString(value: value)
}
else if (mode == 1)
{
return getScientificFormattedString(value: value)
}
else if (mode == 2)
{
return getCurrencyFormattedString(value: value)
}
/
return "???"
}
}
SWIFT_CLASS("_TtC5iMult16DisplayFormatter")
@interface DisplayFormatter : NSObject
@property (nonatomic) NSUInteger mode;
@property (nonatomic) NSUInteger precision;
@property (nonatomic) BOOL useSeperator;
@property (nonatomic, copy) NSString * _Nonnull fieldFormat;
- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
- (void)setFormatStringWithFormatStr:(NSString * _Nonnull)formatStr;
- (NSString * _Nonnull)getDecimalFormattedStringWithValue:(double)value SWIFT_WARN_UNUSED_RESULT;
- (NSString * _Nonnull)getScientificFormattedStringWithValue:(double)value SWIFT_WARN_UNUSED_RESULT;
- (NSString * _Nonnull)getCurrencyFormattedStringWithValue:(double)value SWIFT_WARN_UNUSED_RESULT;
- (NSString * _Nonnull)getFormattedStringWithValue:(double)value SWIFT_WARN_UNUSED_RESULT;
@end