import UIKit
class CheckBoxCell: UITableViewCell {
@IBOutlet weak var lblSchoolName: UILabel!
@IBOutlet weak var btnCheckBox: UIButton!
@IBAction func checkBox(_ sender: Any) {
[Link](.red, for: .normal)
}
}
struct Points{
var x = 0.0, y = 0.0
mutating func moveBy(x deltaX: Double){
print("before = ",self)
//automatic create new instance after it replace existing one with self
x = x + deltaX
print("after = ",self.x)
}
mutating func stepBy(x deltaX: Double){
print("before = ",self.x)
//Assigning to self Within a Mutating Method
self = Points(x: self.x + deltaX, y: self.y)
print("after = ",self.x)
}
static func forwardBy(x deltaX: Double){
print(self)
}
}
class School: UIViewController {
var student = Student() //struture object
var schoolRegistered = false
var schoolRank = 0.0
var schoolName : String = ""
override func viewDidLoad() {
[Link]()
}
}
struct Student {
var studentId = 0
var studentRollNo = 0
}
enum player{
case play, pause, start, stop
mutating func turnPause() {
self = .pause
}
}
let student = Student(studentId: 20, studentRollNo: 30) //Memberwise Initializers
for Structure Types
class ChapterStructureVC:
UIViewController,UITableViewDelegate,UITableViewDataSource{
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) ->
Int {
return 10
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) ->
UITableViewCell {
let cell: CheckBoxCell = [Link](withIdentifier:
"cell", for: indexPath) as! CheckBoxCell
[Link] = "Lorem Ipsum is simply dummy text of the printing
and typesetting industry. Lorem Ipsum has been the industry's standard dummy text
ever since the 1500s, when an unknown printer took a galley of type and scrambled
it to make a type specimen book. It has survived not only five centuries"
// let selected = [UIImage ]
// [Link](, for: UIControlState)
return cell
}
@IBOutlet weak var tableView: UITableView!
override func viewDidLoad() {
[Link]()
func structAndClassInstance(){
let someStudent = Student()
let someSchool = School()
print("someStudent english \([Link])")
print("someSchool math \([Link])")
print("hd resolution \([Link])")
let newStudent = student //structure copied the value
print("cinema width \([Link])") //this has new value
print("hd width \([Link])") //this has old value
}
func abccheck() -> String{
return "Helo world"
}
func callingPrintStruct(){
[Link]()
/*var structObj = Student()
print("Default value \([Link]) and height \
([Link])")
structObj = Student(studentId: 20, studentRollNo: 30)
print("New value \([Link]) and \([Link])")*/
var somePoint = Points(x: 1.0, y: 1.0)
[Link](x: 3)
print("somePoint x = \(somePoint.x) and somePoint y = \(somePoint.y)")
[Link](x: 67)
}
func mutatingFunc(){
var currentState = [Link]
let rememberedState = currentState
[Link]()
print("The current State is \(currentState)")
print("The remembered state is \(rememberedState)")
}
///////////////Class
func classReference(){
let tenEighty = School() //class object create
[Link] = student //class have structure type object so hd is
also structure
[Link] = true
[Link] = "1080i"
[Link] = 25.0
//classes are reference types, tenEighty and alsoTenEighty actually both
refer to the same VideoMode instance.
let alsoTenEighty = tenEighty
print("The frameRate property often Eighty is now \([Link])")
//compare two classes object from ===
if tenEighty === alsoTenEighty{
print("tenEighty and alsoTenEighty refer to the same VideoMode
instance.")
}