Mohsin Qureshi Mohsin Qureshi - 1 year ago 119
iOS Question

How we can Import Objective-C Constants as Swift Types?

I want to declare constant in

Swift 3
. For example if we have following constant in Objective-C :

HK_EXTERN NSString * const HKQuantityTypeIdentifierHeight;
HK_EXTERN NSString * const HKQuantityTypeIdentifierBodyMass;

Answer Source

Add New Swift file : Constant.swift

import Foundation
import HealthKit

let HK_EXTERN_Height : NSString = HKQuantityTypeIdentifierHeight
let HK_EXTERN_BodyMass : NSString = HKQuantityTypeIdentifierBodyMass

Use in ViewController.swift


Hope this help you....

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download