#technology #code #language

idea

<a href="/tags/ifndef.html">#ifndef</a> Torture_h
<a href="/tags/define.html">#define</a> Torture_h

@interface Torture: NSObject
@property NSString *instrument;
- (id) initWithInstrument:(NSString*) instrument;
- (NSString*)applyToVictim:(NSString*)name;
@end

<a href="/tags/endif.html">#endif</a> /* Torture_h */

@implementation Torture

Interop

Use objc in swift

Interop with Swift is done by adding #imports to the bridging header file:

<a href="/tags/import.html">#import</a> "Torture.h"

Then the class can simply be instantiated and called.

Use swift in objc

Use modifier @objc on the swift class.

In the objc .m file, add #import "(projectname)-Swift.h (Project name, not class name). In the objc .h file add @class (classname);