I had many Class Extensions written before, like :
My header file, NSDate+convenience.h:
@interface NSDate (Convenience)
+ (NSDate *)dateFromMyString:(NSString *)dateString
withDateFormatStr:(NSString *)dateFormatStr;
@end
My Obj-C implementation file, NSDate+convenience.m:
@implementation NSDate (Convenience)
+ (NSDate *)dateFromMyString:(NSString *)dateString
withDateFormatStr:(NSString *)dateFormatStr {
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setLocale:[NSLocale currentLocale]];
[formatter setTimeZone:[NSTimeZone localTimeZone]];
[formatter setDateFormat:dateFormatStr];
return [formatter dateFromString:dateString];
}
@end
I use my NSDate Class Extension in objective c by :
[NSDate dateFromMyString:[NSDate date] withDateFormatStr:@"yyyyMMdd-HHmmss-SSS"]
But when want to use it in Swift something like :
NSDate.dateFromMyString(dateString: dateStr, DateFormatStr: "yyyyMMdd-HHmmss-SSS")
or
NSDate.dateFromMyString(bla bla bla ...)
Anyway, the NSDate has no member like 'dateFromMyString', I have many many class extension which I wrote before. Do I need to implement these Class Extension in Swift again.
I have to underline that, I can use my custom normal Obj-C classes properties and methods in Swift, but I can't use a obj-C file that is an extension of the Obj-C. So please do not give me a link 'How to call Objective-C code from Swift' . Please understand my question.