Difference between Swift and Objective – c

Categories:

Syntax:

Swift supports dot (.) oriented syntax, Swift syntax is easy to read-write. Not having square brackets like objective-c.

Open-Source programming language:

As we know swift is an open-source programming language, Apple allows others to push code changes in the master repository of swift after verifying. This means you found anything which could be a more feasible and productive solution than default one. you can suggest those changes/features.

Thats why swift syntax are changing constantly in every version, and swift become easy as pie and flexible in there own way.

Rid of from diffrent declaration and implementation class

No separate class for outlets, property, and object declaration, like no more .h and .m classes for each individual viewController and other cocoa-touch classes.

Import classes

If you want to create an object of any class in objective-c, you have to import this class in derived class but now in swift don’t need to import any class. you can directly access any clas from the bundle and create an object of it without importing this class.

Clean Codebase

if you created a completion handler or block in Objective-C, you know how much disincentive to write such syntax, but in swift, those code syntax is written understandable, and easy to write, For example.

Dispatch main queue in objective c :

dispatch_async(dispatch_get_main_queue(), ^{
   // do work here
});

Dispatch main queue in Swift :

DispatchQueue.main.async { 
// your code
}

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *