pransi_k
pransi_k

Reputation: 11

Generate property of NSObject Class in swift to objective C

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?

Upvotes: 1

Views: 1122

Answers (1)

Jaydeep Vyas
Jaydeep Vyas

Reputation: 4470

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!!!";

Upvotes: 1

Related Questions