1

I am using a NSObject class in Swift, I want to access the property of that class in Objective-C

Below is the class of Swift

class JobCategoryNew:NSObject {

var category_data:String = ""
var category_data_all: [CategoryData] = [CategoryData]()    
}

How can I import JobCategoryNew in my Objective-C file and how to create the object?

Nirmalsinh
  • 4,965
  • 3
  • 21
  • 48
pransi_k
  • 11
  • 3

1 Answers1

1

First follow all the steps given in https://stackoverflow.com/a/41068740/6028575 and finally your swift class should like be

import Foundation

@objc
class JobCategoryNew:NSObject {

   var category_data:String = ""
var category_data_all: [CategoryData] = [CategoryData]() 
}

Usage

JobCategoryNew *obj = [[JobCategoryNew alloc] init];
obj.category_data = @"Testing!!!";
Jaydeep Vyas
  • 4,068
  • 1
  • 15
  • 41