I'm trying to import some category methods into my Swift file without any luck.
ios-Bridging-Header.h:
#import "UIColor+Hex.h"
UIColor+Hex.h
#import <UIKit/UIKit.h>
@interface UIColor (Hex)
+ (UIColor *)colorWithHex:(NSUInteger)hexInt;
+ (UIColor *)colorWithHexString:(NSString *)hexString;
@end
I would expect the autocomplete to reveal UIColor(hexInt: NSUInteger)
and UIColor(hexString: String)
You can use Objective-C categories directly in Swift. This gets really interesting for some of the bridged classes, like String. Extend NSString with a category in Objective-C, and then you can access it from Swift (directly on String!)
The way to do this is by creating a "bridging header" in your Swift project.
Full instructions here.
The short of it is:
#import
statements in itObjective-C Bridging Header
in your Build SettingsActually, your category is transtlated to Swift as follows:
And because of that, you should be using:
Autocompletion may still be buggy in the beta software, though.