News Maffat

We Promote Almost Everything…

img
Home / Technology Updates / Playground in Swift – How to Code in Swift: for Beginners

Playground in Swift – How to Code in Swift: for Beginners

/
/
/

Objective: The main objective of this post is to describe that how to play with swift programming code in iOS. If you play with all code part with new swift language than you play here with on the spot output.

In this post, I’ll show you how you can easily write swift code and each & every line display output on the right side of the screen.

We will simply create a playground area for swift programming language implementation and check different type of things on the screen.

Following are the steps that give you a brief introduction about how to play swift code in playground.

First of all, you must have OS-X 10.9.4 version or later and Xcode-6 Beta version for swift playground.

Step 1:

Open up Xcode and create a playground with clicking on “Get started with a playground” which looks like:

Swift Playgroud
Swift Playgroud

After that, give your playground name and choose platform iOS or OS X doesn’t matter because we don’t interact with user interface and click next and save to your location Which looks like:

Swift Playground Screen
Swift Playground Screen

Step 2:

Here, left hand side white part is used as editor, here, you can write Swift program and right hand side gray part is used as view Result of your code. Here, one example is by default create for var str = “Hello, playground” and similarly, display result on right side.

Step 3:

Now, put some swift code for testing like if-statement, for-loop statement etc.:

for-loop in Playground
for-loop in Playground

Step 4:

Now, some swift code for for-loop statement execution on right hand side give results like 11 times loop executes and on that click on black dote open new part of screen like graph which is shown below:

graph in playground
graph in playground

Step 5:

In graph portion, you can easily understood process of for loop and also, execution time period by graph representation which looks like below.

graph analysis in swift
graph analysis in swift

Conclusion:

After doing all these things, we conclude that for beginner of swift programmar playboard is most useful to know how each & every code works.

In playgound project, we can implement small part of code, which we want to check, and using this we are not handling whole project or entire structure only work with one file, which is myPlayground.playground file.

 

i Hart
i Hart


This post has been seen 680 times.
  • Facebook
  • Twitter
  • Google+
  • Linkedin
  • Pinterest
  • Reddit
It is main inner container footer text