Repository navigation
Add Xcode 7 lightweight generics to make Swift use easier - #54
Conversation
|
Hello @iosdevzone Are these backward compatible? (I haven't tried OC generics yet - super happy when they were announced though) Is this backward backward compatible? If not, I want to tag a new .x version and push that to cocoapods as the final, and start a new major version. Thanks so much for this 🍻 |
|
Hi Jasper, #if __has_feature(objc_generics)
#define NSARRAY_OF(x) NSArray<x>
#define NSDICTIONARY_OF(x,y) NSDictionary<x,y>
#else
#define NSARRAY_OF(x) NSArray
#define NSDICTIONARY_OF(x,y) NSDictionary
#endifThen in the object interfaces use something like: @interface ViewController : UIViewController
@property (nonatomic) NSARRAY_OF(NSString*) *objects;
@property (nonatomic) NSDICTIONARY_OF(NSString*,NSString*) *stringToString;
@endThis approach might simplify fixing bugs in the future (i.e. you would not need to back port them). You probably have a better idea what users of the library want or need so I will defer to your judgement on this. Cheer, |
|
OK, let's just tell folks on older versions to use either a static library, or the last .x version. I'll tag the final .x now and merge this as a new version. |
Add Xcode 7 lightweight generics to make Swift use easier
|
Merged @iosdevzone - thanks so much. Sorry for the delay. |
|
Thanks. I hope folks find the changes useful! |
This PR adds Xcode 7 lightweight generic annotations to various .h files. This makes the library much more pleasant to use in Swift and also adds some compiler checking (during the process I discovered that
-[XCProject configurationWithName]had an incorrect return type!)I did not propagate the annotated types to the .m files since it appears the compiler ignores them (e.g. you can add a different annotation in the .m file and the compiler and static analyzer do not complain).
Since these annotations are only available in Xcode 7 perhaps they should not be merged onto master? It would break builds for folks still on Xcode 6.