What’s new in Swift 4

Apple Worldwide Developer Conference (WWDC) is a conference held annually by Apple to showcase new software and technologies for developers. This year, WWDC is held in San Jose, California from June 5 to June 9 and the fee is 1599 USD. However the registration is only limited to members of the Apple Developer Program or Apple Developer Enterprise Program. Even if you are part of those members, Apple practices random selection picking randomly and if picked, you will be required to pay the fees.

An alternative way to attend WWDC is to qualify for the WWDC 2017 scholarship. Some of the ideas submitted by the students can be found here 

What was announced?

Some of new features include refactoring system on Xcode 9. If you have done programming in different language such as Java using Eclipse, they have a functionality where you could simultaneously rename all variable at the same time which would save you a lot of time.

JSON Encoding & Decoding

String handling on Swift 4 is vastly improved with the ability to handles encoding and decoding making it easier to handle JSON in XCode 9. JSON stands for JavaScript Object Notation and it often sent to and from a server, and used as a data format by any programming language.

What is Encode & Decode?

Encode is a process that put a sequence of characters which consists of either letters, number, punctuation, and certain symbols into a specialized format for efficient transmission or storage.

Decode on the other hand is the opposite process, it is a conversion of an encoded format back into the origin

By implementing Codable protocol, we could convert data representation of JSONThrough this process, we archive the employee into the data object using try statement and the encode(_:) method and the data will be converted into using UTF-8encoding.

Go ahead and see what it will output. If we were to do the opposite which is decode, we will have to write the code below

Play around with the code and see what it does to you if you still do not understand what Encode and Decode does.

Multiple Line String

On Swift 4 allow you to input multiple line of text which would save you a lot of time in writing additional codes. The traditional way of creating multiple line would be including \n at the end of the each line. A better way in Swift 4 allow you to

Strings are Collections

String are now treated as Collections giving you advantages in using collections methods. Some of the method include reversing the strings, looping over them character-by-character saving you the headache of writing additional codes.

There’s more still to come…

  • Article By :
    Founder of DaddyCoding. Studied Computer Science, Information System and Information Technology at BYU-Hawaii. Currently spending most of my time researching and learning on helping to expose making iOS apps.

Random Posts

Leave a Reply

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