Swift 2021 _ Tutorialpoint Flashcards
Define Swift 4?
Apple programming Language - designed for iOS and OSX development
Most recent API compatible?
iOS 6
OSX 10.8
Using Swift, is actually fantastic at?
Developing iOS and OSX developments
Using Swift, provides seamless access?
Existing Cocoa frameworks
Using Swift, unifies what?
Procedural and Object-oriented parts of the lanuage
Is a separate library required for certain functionalities?
NOPE!
Swift 4 comes with X that helps programmers to write and execute code?
Playground!
Getting Started
- install XCode
- open it
- select ‘Get started with a playground’
Swift ‘Hello World’ - Playgound
import UIKit var str = "Hello, playground"
Swift ‘Hello World’ - OSX
import Cocoa var str = "Hello, playground"
‘Hello World’s difference??
import UIKit
VS
import Cocoa
Semicolon - single line - required?
Nope
but optional
Semicolon - for multi lined?
Required!
Special Characters not allowed as Identifiers?
@, $, %
Is Swift case sensitive?
YEs
How to use a reserved word as an identifier?
class
Use ( ` ) - backtick
Whitespaces?
Totally ignored!
Type of Whitespaces?
blanks, tabs, newline characters, AND comments
Correct use of spacing?
int fruit = apples +oranges //is a wrong statement
int fruit = apples + oranges //is a Correct statement
Printing in Swift
3 properties:
- Items
- Separator
- Terminator
print(‘hello world”)
Type Aliases
typealias newname = type
eg
typealias Feet = Int
Type Safety means?
if part of your code expects a String you cannot pass it an ‘int’ by mistake
Cannot assign error?
main.swift:2:8: error: cannot assign value of type ‘String’ to type ‘Int’
varA = “This is hello”
Type Annotations are spelled out:
var variableName: =