-2

I have an Objective-C project, there is a file named 'NSDictionary+Test', and a method named - (void)testDone:(TestBlock)block in the file. I add a swift file to the project , how can i use - (void)testDone:(TestBlock)block in my Swift file.

Ahmad F
  • 30,560
  • 17
  • 97
  • 143
Sunxb
  • 81
  • 1
  • 7

1 Answers1

0

So firstly you have your Objective C proj and in it you have your category(in Obj C) and now you added a Swift file and want to use category method in Swift.

So now answer goes-

  1. Firstly add your .swift file and mostly it asks for creating a bridging header. If it does not get created, follow the steps from this.

  2. Add #import "NSDictionary+Test.h" before #endif.

  3. Now you should be able to use the (void)testDone:(TestBlock)block as dictionary.testDone(block : TestBlock!).

arlomedia
  • 8,534
  • 5
  • 60
  • 108
Nikhil Manapure
  • 3,748
  • 2
  • 30
  • 55