real swift. real ios. - web viewreport week. swift and ... (inputkejuruan.text!) // declare average....

33
REPORT WEEK SWIFT AND XCODE Teacher : Rizki Syaputra, S.ST Write by : Arjuna wika pratama - 171803007 RPL 2 SMK IDN MADINATUL ILMI REKAYASA PERANGKAT LUNAK (RPL) T.A 2017 /2018

Upload: hatuong

Post on 30-Jan-2018

225 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Real Swift. Real iOS. - Web viewREPORT WEEK. SWIFT AND ... (InputKejuruan.text!) // declare average. let ... Yang dapat kita ambil dari contoh di atas adalah untuk menghasilkan sesuatu

REPORT WEEK SWIFT AND XCODE

Teacher :

Rizki Syaputra, S.ST

Write by :

Arjuna wika pratama - 171803007

RPL 2

SMK IDN MADINATUL ILMI

REKAYASA PERANGKAT LUNAK (RPL)

T.A 2017 /2018

Page 2: Real Swift. Real iOS. - Web viewREPORT WEEK. SWIFT AND ... (InputKejuruan.text!) // declare average. let ... Yang dapat kita ambil dari contoh di atas adalah untuk menghasilkan sesuatu

Modul

Swift

Swift is a robust and intuitive programming language created by Apple to develop apps for iOS, Mac, Apple TV and Apple Watch. This language is designed to give developers more freedom. Swift is easy to use and open source, so anyone who has ideas can create something out of the ordinary. Swift is a fast and efficient language that provides reports in real-time and can be seamlessly integrated into existing Objective-C code. So, developers can write code that is more secure and reliable, time saving, and even richer experience in creating applications.

Example code for swift :

var implicitInteger = 70var implicitDouble = 70.0var explicitDouble: Double = 70let jumlahApel = 3let jumlahJeruk = 5let ringkasanApel = "Saya punya \(jumlahApel) apel."let ringkasanJeruk = "Saya punya \(jumlahApel + jumlahJeruk) buah."

MODUL

Swift Playground

Swift Playgrounds is a revolutionary iPad app that helps you learn and explore coding in Swift, the same powerful language used to create world-class apps for the App Store. Engaging lessons and challenges help students learn the core concepts of coding by writing real Swift and iOS code in an interactive environment designed for touch.In Swift Playgrounds you create small programs called “playgrounds” that instantly show the results of the code that you write. A single

Page 3: Real Swift. Real iOS. - Web viewREPORT WEEK. SWIFT AND ... (InputKejuruan.text!) // declare average. let ... Yang dapat kita ambil dari contoh di atas adalah untuk menghasilkan sesuatu

line of code can make amazing things happen. Interactive lessons teach key coding concepts, and additional challenges and templates encourage you to explore code in exciting new ways and to create something completely unique. There are even playgrounds that use Bluetooth to control robots, drones, and other hardware accessories. It’s easy to share your creations with friends, or record and post videos of your playgrounds in action.

Coding ConceptsSwift Playgrounds includes interactive lessons that use puzzles and experimentation to teach the following core coding concepts, and more:

Commands Functions Parameters Loops Conditional statements Variables Operators Types Initialization

Real Swift. Real iOS.The Swift programming language was designed to be approachable enough to be your very first programming language. Swift is also incredibly powerful, used by professional developers to create thousands of apps in the App Store. Using Swift Playgrounds, you will code real programs within minutes and even as you become more proficient, you will never outgrow Swift.

Swift Playgrounds also gives you access to iOS frameworks such as UIKit, SpriteKit, SceneKit, bluetooth, and Metal. And because you are coding and running your playgrounds on iPad, your code can respond to touch gestures or interact with hardware such as the accelerometer and gyroscope.

Experiment with Code

Sometimes the best way to learn is to explore on your own, and Swift Playgrounds is a great place to let your imagination run wild. In addition to the lessons that help you learn to code, Swift Playgrounds delivers new challenges on a regular basis so you can keep coming back to try something new. Some challenges are fun ways to play with code to create interesting effects, while others include engrossing puzzles that requires all of your coding skills to solve.

Page 4: Real Swift. Real iOS. - Web viewREPORT WEEK. SWIFT AND ... (InputKejuruan.text!) // declare average. let ... Yang dapat kita ambil dari contoh di atas adalah untuk menghasilkan sesuatu

Additional templates included in Swift Playgrounds help you get started creating a playground from scratch. With access to thousands of APIs in the iOS SDK, you can create amazing playgrounds that explore the web, generate 3D worlds, experiment with physics, and much more.

The included playgrounds can be edited, extended, remixed, or completely reinvented. Collaborate with friends or reimagine them on your own.

Built for TouchBecause Swift Playgrounds was designed from the ground up for touch, you can create entire programs with only a few taps on the iPad screen. Unique coding features include:

QuickType for code. The Shortcut Bar intelligently presents the most likely next commands or values based on context. Its easy to write entire lines of code without touching a keyboard.

Touch to edit. Tap to edit a number in-place with a pop-over keypad, or touch a color value to display a color picker. You can even restructure your code by simply dragging a brace to wrap around the surrounding code.

Library of snippets. Common code snippets such as loops, structures, and switch statements can be dragged out of a library to create new code with a lot less typing.

Coding keyboard. Quickly type numbers and symbols commonly used in Swift coding by simply dragging your finger across a key to select one of the alternate symbols.

Swift Playgrounds helps you write correct code by identifying mistakes as you type, and offers suggestions to help correct the errors.

MODUL X CODE

Xcode is an integrated development environment for macOS containing a suite of software development tools developed by Apple for developing software for macOS, iOS, watchOS and tvOS. First released in 2003, the latest stable release is version 8.3.3 and is available via the Mac App Store free of

Page 5: Real Swift. Real iOS. - Web viewREPORT WEEK. SWIFT AND ... (InputKejuruan.text!) // declare average. let ... Yang dapat kita ambil dari contoh di atas adalah untuk menghasilkan sesuatu

charge for macOS Sierra usersRegistered developers can download preview releases and prior versions of the suite through the Apple Developerwebsite. However, Apple recently made a beta version of version 9 beta 2 of the software available to those of the public with Apple Developer accounts.

so in the picture above is about xcode we will learn Playground is a special type of Xcode file. You can simply click "Get started with a playground" to get started. You'll then be prompted to fill in a project name and select a platform.

Page 6: Real Swift. Real iOS. - Web viewREPORT WEEK. SWIFT AND ... (InputKejuruan.text!) // declare average. let ... Yang dapat kita ambil dari contoh di atas adalah untuk menghasilkan sesuatu

Figure 2-2. Creating a Playground fileUse the default name or choose your own name but remember to select iOS as the platform. Once you confirm to save the file, Xcode opens the Playground interface. Your screen should like this:

On the left pane of the screen, it is the editor area where you type your code. As you write your code, Playground immediately interprets your code and displays the result on the right pane. By default, Playground includes two lines of code. As you can see, the result of the str variable appears immediately on the right pane.

Page 7: Real Swift. Real iOS. - Web viewREPORT WEEK. SWIFT AND ... (InputKejuruan.text!) // declare average. let ... Yang dapat kita ambil dari contoh di atas adalah untuk menghasilkan sesuatu

We'll write some code in Playgrounds together. Remember the purpose of this exercise is to let you experience Swift programming and get a better idea of Xcode. I'll try to explain parts of the code as we move along. For now, even if you do not understand any line of the code, that is completely fine. I'm quite sure you'll be confused by some of the terms like class and method. Forget about their meanings, just relax and play around with Xcode. We'll go over them again in later chapters.Cool! Let's get started.First, key in a couple lines of code. Here we declare two more variables:var message1 = "Hello Swift! How can I get started?"var message2 = "The best way to get started is to stop talking and code."As soon as you insert the above lines of code, you will see the result on the right pane.

Figure 2-4. Result is shown immediately on the right paneLet's continue to add the following line of code:message1.uppercased()Xcode's editor comes with an auto-complete feature. Auto-complete is a very handy feature to speed up your coding. Once you type mess, you'll see an auto-complete window showing some suggestions based on what you have keyed in. All you need to do is to select message1 and hit enter.

Swift employs the dot syntax for calling methods and accessing the properties of a variable. As you type the dot after message1, the auto-complete window pops out again. It suggests a list of methods and properties belonged to the variable. You can continue to type uppercase() or select it from the auto-

Page 8: Real Swift. Real iOS. - Web viewREPORT WEEK. SWIFT AND ... (InputKejuruan.text!) // declare average. let ... Yang dapat kita ambil dari contoh di atas adalah untuk menghasilkan sesuatu

complete window.

Once you complete your typing, you would see the output immediately. When we use uppercase() on message1, the content of message1 is converted to upper case automatically.Continue to type the following line of code:message2.lowercased() + " Okay, I'm working on it "Swift allows you to concatenate two strings with the + operator. The line of code converts the content of message2 into lower case and then concatenated with another string. Interestingly, you can include emoji characters in your code. You may wonder how to type emoji characters in Mac OS. It's easy. Just press control-command-spacebar and an emoji picker will be displayed.Let's continue to type the following code snippet:if message1 == message2 { print("Same message")} else { print("Not the same message")}Conditional logic is very common in programming. Sometimes, you want to execute certain part of code only when a certain condition is met. An if-else statement is one of the ways in Swift to control program flow. Here we compare the content of message1 and message2 variables using the == operator. If they're equal, the program prints "Same message". Otherwise, it prints "Not the same message". You should see the following result on your screen.

Page 9: Real Swift. Real iOS. - Web viewREPORT WEEK. SWIFT AND ... (InputKejuruan.text!) // declare average. let ... Yang dapat kita ambil dari contoh di atas adalah untuk menghasilkan sesuatu

Modul

Project InputName1.First create a project on xcode by selecting create new xcode project 2.Then the display appears as below, select Single View Application

3.Then fill in the data as follows:

4. Then select the location of the project storage

Page 10: Real Swift. Real iOS. - Web viewREPORT WEEK. SWIFT AND ... (InputKejuruan.text!) // declare average. let ... Yang dapat kita ambil dari contoh di atas adalah untuk menghasilkan sesuatu

5. after the project is completed it will appear like this

6.Then to start the project work, we design layout view first on Main.Storyboard. On Main.Storyboard create a look like this

Page 11: Real Swift. Real iOS. - Web viewREPORT WEEK. SWIFT AND ... (InputKejuruan.text!) // declare average. let ... Yang dapat kita ambil dari contoh di atas adalah untuk menghasilkan sesuatu

7.The widget declaration we use to viewcontroller.swift by clicking onicon circle show the assistant For widget declaration can be used by drag and drop widget, andwhen we drag make sure press the Control key

After all the widgets have been declared, it will appear code in view controller.swift as below:

Page 12: Real Swift. Real iOS. - Web viewREPORT WEEK. SWIFT AND ... (InputKejuruan.text!) // declare average. let ... Yang dapat kita ambil dari contoh di atas adalah untuk menghasilkan sesuatu

//// ViewController.swift// laporan1//// Created by Arjuna Wika Pratama on 9/9/17.// Copyright © 2017 Arjuna Wika Pratama. All rights reserved.//

import UIKit

class ViewController: UIViewController {

@IBOutlet weak var welcome: UILabel! @IBOutlet weak var inputnama: UITextField! @IBOutlet weak var hy1: UILabel! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. }

9. The next step is to add the button on the button, for the button make sure you do the coding in the section as below:

10. Add the following codes:

Page 13: Real Swift. Real iOS. - Web viewREPORT WEEK. SWIFT AND ... (InputKejuruan.text!) // declare average. let ... Yang dapat kita ambil dari contoh di atas adalah untuk menghasilkan sesuatu

11. Now run the app by clicking play mark on your xcode project, wait a moment then it will look like this:

12. Adding a username to its text field input and then press submit button it will look like this:

Page 14: Real Swift. Real iOS. - Web viewREPORT WEEK. SWIFT AND ... (InputKejuruan.text!) // declare average. let ... Yang dapat kita ambil dari contoh di atas adalah untuk menghasilkan sesuatu

13. and in the end you can see this

Modul

Input Results Count1. Then fill in the data as follows

Page 15: Real Swift. Real iOS. - Web viewREPORT WEEK. SWIFT AND ... (InputKejuruan.text!) // declare average. let ... Yang dapat kita ambil dari contoh di atas adalah untuk menghasilkan sesuatu

2. Then select the location of the project storage

3.after the project is completed it will appear like this

4. Then to start the project work, we design layout view first on Main.Storyboard. On Main.Storyboard create a look like this

Page 16: Real Swift. Real iOS. - Web viewREPORT WEEK. SWIFT AND ... (InputKejuruan.text!) // declare average. let ... Yang dapat kita ambil dari contoh di atas adalah untuk menghasilkan sesuatu

5. The widget declaration we use to viewcontroller.swift by clicking onicon circle show the assistant For widget declaration can be used by drag and drop widget, andwhen we drag make sure press the Control key

6. After all the widgets have been declared, it will appear code in view controller.swift as below://// ViewController.swift// latihan tanggal 5sep//

Page 17: Real Swift. Real iOS. - Web viewREPORT WEEK. SWIFT AND ... (InputKejuruan.text!) // declare average. let ... Yang dapat kita ambil dari contoh di atas adalah untuk menghasilkan sesuatu

// Created by Arjuna Wika Pratama on 9/5/17.// Copyright © 2017 Arjuna Wika Pratama. All rights reserved.//

import UIKit

class ViewController: UIViewController {

@IBOutlet weak var InputMTK: UITextField! @IBOutlet weak var InputBahasa: UITextField! @IBOutlet weak var InputKejuruan: UITextField! @IBOutlet weak var InputEnglish: UITextField! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. }

7.The next step is to add the button on the button, for the button make sure you do the coding in the section as below:

// declare dari outlate ke action} @IBAction func btn(_ sender: Any) {

8. Add the following codes:

// declare dari outlate ke action

Page 18: Real Swift. Real iOS. - Web viewREPORT WEEK. SWIFT AND ... (InputKejuruan.text!) // declare average. let ... Yang dapat kita ambil dari contoh di atas adalah untuk menghasilkan sesuatu

@IBAction func btn(_ sender: Any) { //declare nilaiMTK let nilaiMTK : Int? = Int(InputMTK.text!) //declare nilaiEnglish let nilaiEnglish : Int? = Int(InputEnglish.text!) //declare nilai bahasa let nilaiBahasa : Int? = Int(InputBahasa.text!) //declare nilai Kejuruan let nilaiKejuruaan : Int? = Int(InputKejuruan.text!)

// declare average let hasilhitung : Int = (nilaiMTK! + nilaiBahasa! + nilaiEnglish! + nilaiKejuruaan!) / 4 YourAve.text = "your avg = \(hasilhitung)"

9. Now run the app by clicking play mark on your xcode project, wait a moment then it will look like this:

Modul

Page 19: Real Swift. Real iOS. - Web viewREPORT WEEK. SWIFT AND ... (InputKejuruan.text!) // declare average. let ... Yang dapat kita ambil dari contoh di atas adalah untuk menghasilkan sesuatu

Quiz1. Createnew ios application for program input 2 integer from textfield and after that

program will calculate that data use arithmetic operator like +, -, * / , % and show the result into label

2. Create new ios application for program to know how many time to travel with input distance and speed. And show that time into label.Formula : time = distance / speed

3. Create new ios application to calculate wide of triangle area. With formula : Luas = (alas * tinggi) / 2

4. Create new ios application to know wide circle with input 5 radius of circle and then show that wide of circle to 5 label

1.

//// ViewController2.swift// tugastgl6sep//// Created by Arjuna Wika Pratama on 9/6/17.// Copyright © 2017 Arjuna Wika Pratama. All rights reserved.//

import UIKit

class ViewController2: UIViewController { @IBOutlet weak var n1: UITextField! @IBOutlet weak var n2: UITextField! @IBOutlet weak var plus: UILabel! @IBOutlet weak var minus: UILabel!

Page 20: Real Swift. Real iOS. - Web viewREPORT WEEK. SWIFT AND ... (InputKejuruan.text!) // declare average. let ... Yang dapat kita ambil dari contoh di atas adalah untuk menghasilkan sesuatu

@IBOutlet weak var multiplied: UILabel! @IBOutlet weak var mod: UILabel! @IBOutlet weak var divide: UILabel! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. } @IBAction func hasilhitung(_ sender: Any) { //declare number 1 let number1 : Int? = Int(n1.text!) //declare number 2 let number2 : Int? = Int(n2.text!) //declare plus let hasilhitung : Int = number1! + number2! plus.text = "hasil = \(hasilhitung)" //declare minus let hasilHitungminus: Int = number1! - number2! minus.text = "hasil = \(hasilHitungminus)" //declare multiplied let hasilHitungmulti: Int = number1! * number2! multiplied.text = "hasil = \(hasilHitungmulti)" //declare mod let hasilhitungmod : Int = number1! % number2! mod.text = "hasil = \(hasilhitungmod)" //declare divide let hasilhitungdivide : Int = number1! / number2! divide.text = "hasil = \(hasilhitungdivide)"2.

Page 21: Real Swift. Real iOS. - Web viewREPORT WEEK. SWIFT AND ... (InputKejuruan.text!) // declare average. let ... Yang dapat kita ambil dari contoh di atas adalah untuk menghasilkan sesuatu

.

//// ViewController3.swift// tugastgl6sep//// Created by Arjuna Wika Pratama on 9/6/17.// Copyright © 2017 Arjuna Wika Pratama. All rights reserved.//

import UIKit

class ViewController3: UIViewController {

@IBOutlet weak var waktu: UILabel! @IBOutlet weak var jarak: UITextField! @IBOutlet weak var cepat: UITextField! override func viewDidLoad() { super.viewDidLoad()

// Do any additional setup after loading the view. } @IBAction func waktu(_ sender: Any) { // declare jarak let jarak1 : Int? = Int(jarak.text!) //declare cepat let cepat1 : Int? = Int(cepat.text!) // formula let hasilhitung : Int = (jarak1! / cepat1!) waktu.text = "hasilwaktu =\(hasilhitung)" }

override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. }

Page 22: Real Swift. Real iOS. - Web viewREPORT WEEK. SWIFT AND ... (InputKejuruan.text!) // declare average. let ... Yang dapat kita ambil dari contoh di atas adalah untuk menghasilkan sesuatu

/* // MARK: - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation override func prepare(for segue: UIStoryboardSegue, sender: Any?) { // Get the new view controller using segue.destinationViewController. // Pass the selected object to the new view controller. } */

@IBOutlet weak var hasil: UILabel!}

1. What is the definition of Algoritm

2. Who is the founder of Algorithm

3. What is database and xampp

4. Create algorithm for program to know how many time to travel with input distance

and speed. And show that time into label. Formula : time = distance / speed

5. What is Swift

6. What is Xcode

7. Please explain about data type and arithmetic logic in program

8. Explain about var and let In swift

9. What is playground in xcode ?

1. Algoritma merupakan tahapan-tahapan untuk mencapai hasil. Jadi Algoritma tidak selalu berhubungan dengan Ilmu Komputer. Misalkan cara membuat cake. Pertama kita harus mempersiapkan adonan cake. Kemudian apabila adonan tersebut telah jadi, panaskan oven. Kemudian taruh adonan cake tersebut kedalam Loyang yang telah dioleskan mentega dan ditaburi sedikit tepung. Apabila adonan tersebut telah dimasukkan kedalam Loyang,masukkan Loyang yang berisi adonan cake tersebut kedalam oven yang telah di tentukan suhunya tadi. Tunggulah kira-kira setengah jam. Maka adonan cake tersebut akan menjadi kue cake.Di sini saya bukan membahas tentang kue cake, tapi saya hanya memberi gambaran logis tentang pengertian Algoritma yang sebenarnya. Yang dapat kita ambil dari contoh di atas adalah untuk menghasilkan sesuatu,maka diperlukan

Page 23: Real Swift. Real iOS. - Web viewREPORT WEEK. SWIFT AND ... (InputKejuruan.text!) // declare average. let ... Yang dapat kita ambil dari contoh di atas adalah untuk menghasilkan sesuatu

proses. Proses tersebut terdiri dari tahapan-tahapan yang logis. Jadi menurut pemikiran saya,secara umum Inti dari algoritma adalah tahapan-tahapan logis yang harus dipenuhi untuk mencapai suatu hasil.Sekarang saya akan membahas Algoritma menurut pengertian ilmu Komputer. Algoritma dalam ilmu Komputer adalah urut-urutan yang logis dan tepat untuk memecahkan permasalahan yang menggunakan Komputer dengan bahasa pemrograman yang telah ditentukan seperti bahasa pascal, Visual Basic, C, atau yang lainnya. Untuk membuat sebuah program, seseorang harus memiliki daya pikir yang bagus. Dan untuk menghasilkan sebuah program yang berbeda dengan yang lainnya, maka orang tersebut harus memiliki kreativitas.Kata Algoritma berasal dari bahasa arab yaitu Algorism yang berarti proses menghitung dengan angka arab. Sedangkan Algorist adalah orang yang menghitung dengan menggunakan angka arab. Sebenarnya, Algoritma itu sendiri berasal dari nama seorang ahli matematika dari Uzbekistan yaitu Abu Abdullah Muhammad Ibn Musa al-Khwarizmi yang dibaca oleh orang barat menjadi Algorism.

2. Algoritma itu sendiri berasal dari nama seorang ahli matematika dari Uzbekistan yaitu Abu Abdullah Muhammad Ibn Musa al-Khwarizmi yang dibaca oleh orang barat menjadi Algorism.

3. Basis data (database) adalah kumpulan data yang disimpan secara sistematis di dalam komputer yang dapat diolah atau dimanipulasi menggunakan perangkat lunak (program aplikasi) untuk menghasilkan informasi. Pendefinisian basis data meliputi spesifikasi berupa tipe data, struktur data dan juga batasan-batasan pada data yang akan disimpan. Basis data merupakan aspek yang sangat penting dalam sistem informasi karena berfungsi sebagai gudang penyimpanan data yang akan diolah lebih lanjut. Basis data menjadi penting karena dapat mengorganisasi data, menghidari duplikasi data, menghindari hubungan antar data yang tidak jelas dan juga update yang rumit.

XAMPP (/[unsupported input]ˈzæmp/ atau /ˈɛks.æmp/

[1]

) adalah perangkat lunak bebas, yang mendukung banyak sistem operasi, merupakan kompilasi dari beberapa program.

Page 24: Real Swift. Real iOS. - Web viewREPORT WEEK. SWIFT AND ... (InputKejuruan.text!) // declare average. let ... Yang dapat kita ambil dari contoh di atas adalah untuk menghasilkan sesuatu

Fungsinya adalah sebagai server yang berdiri sendiri (localhost), yang terdiri atas program Apache HTTP Server, MySQL database,dan penerjemah bahasa yang ditulis dengan bahasa pemrograman PHP dan Perl. Nama XAMPP merupakan singkatan dari X (empat sistem operasi

apapun), Apache, MySQL, PHP dan Perl. Programini tersedia dalam GNU General Public License dan bebas, merupakan web server yang mudah digunakan yang dapat melayani tampilan halaman web yang dinamis. Untuk mendapatkanya dapat mendownload langsung dari web resminya.

4.

.

5. pemrograman yang dikembangkan oleh Apple Inc. Untuk pengembangan aplikasi di dalam platform khusus buatan Apple Inc. Bahasa ini termasuk dalam golongan objek fungsional (Functional - Object), dan dirancang agar dapat bekerja dengan Objective-C. Swift dibuat pada tahun 2014, tepatnya pada acara WWDC. Bahasa ini juga bahasa pengantarnya para mac developer ,iOS developerdan platform Apple lainnya. Serta dapat dipastikan anda tahu kalau aplikasi pada platfrom Apple mayoritas berbayar.

6. Xcode is an integrated development environment for macOS containing a suite of software development tools developed by Apple for developing software for macOS, iOS, watchOS and tvOS. First released in 2003, the latest stable release is version 8.3.3 and is available via the Mac App Store free of

charge for macOS Sierra users.

[2]

Registered developers can download preview releases and prior versions of the suite through the Apple

Page 25: Real Swift. Real iOS. - Web viewREPORT WEEK. SWIFT AND ... (InputKejuruan.text!) // declare average. let ... Yang dapat kita ambil dari contoh di atas adalah untuk menghasilkan sesuatu

Developerwebsite.

[3]

However, Apple recently made a beta version of version 9 beta 2 of the software available to those of the public with Apple Developer

accounts.

[

.

8.Pada saat kita ingin membuat sebuah variable yang bernilai constant atau tidak akan berubah nilainya maka kita bisa menggunakan let. Jadi setiap variable yang kita buat dengan menggunakan let maka sebuah variable tersebut tidak akan berubah nilainya. Berikut ini adalah contoh membuat sebuah variable dengan menggunakan let : let umur: Int = 23

varDengan menggunakan var ini kita bisa mengubah atau memanipulasi data atau variable nya. Gunakan var ini ketika kita ingin membuat sebuah variable yang datanya atau nilainya akan dinamis atau berubah — ubah. Dan berikut ini cara membuat sebuah varibale dengan menggunakan var :

Page 26: Real Swift. Real iOS. - Web viewREPORT WEEK. SWIFT AND ... (InputKejuruan.text!) // declare average. let ... Yang dapat kita ambil dari contoh di atas adalah untuk menghasilkan sesuatu

var jumlahKunjungan: Int = 12

Pada umumnya lebih baik kita menggunakan let jika kita akan membuat sebuah variable, akan tetapi jika variable akan berubah nilainya gunakan let.

7. Data type :

 Interger : 0,1,2,3,4,5,6 and so on

 Float : 2,5 and so on

 Double : 2,55 and so on

 Varchar : RIZKI , ARJUNA

 Char : R,I,Z,K,I

Operator sign :

o  = : equal

o  != : not equal

o  >= : bigger than

o  <= : small than

o  % : mod

o  / : divide

o  * : multiply

o  $$ : and

o  ! : or

Bolean:

 true : ==

Page 27: Real Swift. Real iOS. - Web viewREPORT WEEK. SWIFT AND ... (InputKejuruan.text!) // declare average. let ... Yang dapat kita ambil dari contoh di atas adalah untuk menghasilkan sesuatu

 false : !=

 Operator Aritmatik  Operator ini membentuk perhitungan aritmatik. Kedua

operan dari operasi aritmatik ini dapat berupa nilai integer atau real.

 Operator yang termasuk tipe ini adalah:

Output dari operasi aritmatik akan memiliki tipe data yang

sama dengan tipe data kedua operannya. Misalnya, jika sebuah bilangan integer dijumlahkan dengan bilangan integer lainnya maka outputnya adalah bilangan integer juga. Selain itu perlu diperhatikan pula bahwa sebuah operator aritmatik tidak dapat diterapkan pada dua bilangan dengan tipe data yang berbeda.

9Playground adalah sebuah wadah yang bisadigunakan oleh developers untuk mencoba kode- kode dalam bahasa Swift dan langsung melihat hasilnya secara realtime, artinya kita tidak perlu compile dan run secara manual. Tampilan dari playground adalah sebagai berikut.