user3778432
user3778432

Reputation: 71

Method name changed from Obj C to swift

It's not a big problem, but I was a bit confused when I faced it for the first time. This was the original declaration for an Obj C delegate method:

- (void)serialPortWasRemovedFromSystem:(ORSSerialPort *)serialPort 

And when I translated it in swift it became:

func serialPortWasRemovedFromSystem(_ serialPort: ORSSerialPort)

But later Xcode showed an error and suggested me to change the name, because it was deprecated, in this one:

func serialPortWasRemoved(fromSystem serialPort: ORSSerialPort)

Why did they change this delegate name so many times? Can you tell me why? Thank you! ~

Upvotes: 2

Views: 2055

Answers (2)

sishin
sishin

Reputation: 119

I agree with @matt. The Objective-C APIs are "renamified" to make their names terser and more Swift-like

// Objective-c SampleObC.h
@interface SampleObC : NSObject
 +(void)getSampleName;
 +(void)setSampleName;
}

// Swift 
class SampleSwift {
  // Sample Class Name is ignored.
  SampleObC.getName()
  SampleObC.setName()
}

Upvotes: -1

matt
matt

Reputation: 534977

Because that, in large part, is what Swift 3 is. The Objective-C APIs are "renamified" to make their names terser and more Swift-like.

To learn more, read this and the other two documents to which it links.

Upvotes: 2

Related Questions