Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

difference between struct and class swift

Struct : Value Type | No Inheritance | No Deinitializers | No Type casting
Class : Reference Type | Inheritance supported | Has Deinitializers | Type casting

Common factors between struct and class:
Both allows to define properties to store values
Both allows to define methods
Both allows to define subscripts 
Both allows to define initializers
Both allows extension and protocols 
Comment

Struct Vs Class in Swift

class Bike {
  var color: String

  init(color:String) {
    self.color = color
  }
}

var bike1 = Bike(color: "Blue")

var bike2 = bike1

bike1.color = "Red"
print(bike2.color)  // prints Red
Comment

PREVIOUS NEXT
Code Example
Swift :: string to json swift 
Swift :: How to find index of list item in Swift? 
Swift :: closure swift 
Swift :: hex color extension swift 
Swift :: swift add width/height constraint to view 
Swift :: Swift Basic Input 
Swift :: switch case in swift language 
Swift :: uibutton swift set title color 
Swift :: swift make condition that you are in sumulator 
Swift :: swift dictionary get key from valye 
Swift :: map swift 
Swift :: swift inheritance 
Swift :: create button with icon swift 
Swift :: swift remove all pins from mapkit 
Swift :: response.result.value alamofire 5 
Swift :: how to make month format in swift 
Swift :: parse int in swift 
Swift :: how to change background color swift 
Swift :: Swift Half-Open Range 
Swift :: table view content size not return correctly 
Swift :: Customize indicator view iOS swift 
Swift :: auto layout issue in tableview 
Swift :: SwiftUI cant tap in spacer of HStack 
Swift :: swift open messages app 
Swift :: Iterate Over enum Cases Swift 
Swift :: xib image shown on simulator but not on device 
Swift :: Swift Left Shift Operator 
Swift :: Swift Modify the Elements of an Array 
Swift :: swift enumeration 
Ruby :: devise generate controller 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =