Person *mPerson = [[[Person alloc] init] autorelease]; -(void)dealloc{ [mPerson release] [super dealloc] } //2017 - Swift3 var person = Person() var person:Person? = nil var person: Person = Person()
address of another variable - its direct address of memory location. Person *mPerson Swift You can use pointers in swift as well but since swift is memory safe so it prevents direct access of memory. A pointer encapsulates a memory address. Types that involve direct memory access get an “unsafe” prefix so the pointer type is called UnsafePointer. let pointer = UnsafeMutablePointer<Int>.allocate(capacity: count)
case D } var example = Example.A example = .B enum Types { case Str(String) case Num(Double) } var a = Types.Str("hello") a = .Num(1.0) switch a { case .Str(let val): print(val) case .Num(let val): print(val) } Enum //Class class Example2 { var a = 0 var b = 0 init(_ a: Int, _ b: Int) { self.a = a self.b = b } } let example2 = Example2(1, 2) print(example2.a) print(example2.b) //Tuples var letters = ("a", "b") let (first, second) = letters print(first) // a print(second) // b var (a, _) = letters print(a) // a print(letters.0) // a print(letters.1) // b var letters2 = (first: "a", second: "b") print(letters2.first) // a print(letters2.second) // b
using tools Add Bridging headers Do class forward Declaration for using class from swift file to Objective-c User @objc keyword Check for Swift type Compatibility
(nonnull instancetype)initWithSongs:(NSArray<NSString *> * __nonnull)songs OBJC_DESIGNATED_INITIALIZER; //Declaring swift protocol that can be used in Objective-c Class @objc public protocol MySwiftProtocol { func requiredMethod() @objc optional func optionalMethod() } //Adopting swift Protocol in Objective-C implementation @interface MyObjcClass () <MySwiftProtocol> // ... @end @implementation MyObjcClass // ... @end
improve and decide topics for next meet up. Become speaker and share your knowledge and experience. We are keen on improvising, its possible with your feedback https://goo.gl/Zm9YdP