May 1st, 2017
Swift is a new programming language that is purely compatible with objective C. This makes it possible to use objective C file code in Swift file. Apple claims the co-existence of Swift and Objective C in an application but, this does not relate to re-using old classes made in Objective-C whilst building new classes in Swift. The reason being as Objective-C is a platform-independent language unlike Swift is platform-dependent. Now, implementing non-platform-dependent code in Swift won’t be fruitful. henceforth, writing platform dependent code in Swift would be absolutely fine.
In this post we will learn the basics of how to use CocoaSpirit for interacting with Objective-C. Let us consider the following example.
Example of Objective-C class
@interface Object1 : NSObject
@property id value1;
@property NSArray *array1;
– (void)selector1;
– (void)selector2:(id)arg1 withArg2:(id)arg2;
@end