Skip to content

patiljignesh/iOS-Swift-with-First-Principles

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

iOS Swift using First Principles

Topics

  1. Auto layout

  2. SSL Pinning

  3. Using Containers

  4. StackViews

    • View embeded with other views
  5. MVC

  6. Mutating Methods within Struct

    • Enable changes to the variable within the Struct when invoking
    • "The problem is that when you create the struct Swift has no idea whether you will use it with constants or variables, so by default it takes the safe approach: Swift won’t let you write methods that change properties unless you specifically request it." ~ HackingWithSwift
  7. Setting current Button Title via code: button.setTitle("my text here", forState: .normal)

  8. Rounding off a Float or other value: print(String(format: "%.2f", sender.value))

  9. Struct vs Classes

  10. CGRect : Core Graphics Rectangle

  11. Adding to View by code/ Programatically:

// Inside viewDidLoad()
view.backgroundColor = .red        
let label = UILabel()
label.text = "Hello Second View controller"
label.frame = CGRect(x: 0, y: 0, width: 100, height: 50)
view.addSubview(label)
  1. Downcasting let destinationVC = segue.destination as! ResultViewController

  2. String let str = String(format: "%.2f", 1.2334) RESULT: 1.23

  3. UIViewController Nagivation:

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    if segue.identifier == "MySegueId" {
        if let nextViewController = segue.destination as? NextViewController {
                nextViewController.valueOfxyz = "XYZ" //Or pass any values
                nextViewController.valueOf123 = 123
        }
    }
}
  1. Scalar Images vs Vector Images

rastervsvector

  1. Dismiss the keyboard: searchTextField.endEditing(true)

  2. Type Alias:

  • Example: Codable is a type alias for the Encodable and Decodable protocols. When you use Codable as a type or a generic constraint, it matches any type that conforms to both protocols.
  1. Defining Extension
extension SomeType {
   // Add new functionality
   // It could extention to a class, struct, protocol
}

  1. Create sections in the file: //MARK: - {Secion Name}

  2. Control flow

  3. Localized is referenced to local language that the user has selected. Eg. localizedDescription is a description which will be displayed in user's local device language which has been set by the user.

  4. [weak self]

Understanding weak self in programming, especially in the context of Swift, involves a few concepts related to memory management. let's deep dive

  1. Type Properties vs Instant Properties
  • There will only ever be one copy of these properties, no matter how many instances of that type you create. These kinds of properties are called type properties.

  1. is is used for Type Checking

  2. as! is used for Forced Downcast

  3. as? is used for Safe Downcast

  4. as is used for Upcasting. From subclass to superclass.

  5. Understanding App Lifecyle

  6. Local Data Persistance using User Defaults, Core Data and Realm

  7. Core Data and more

  8. Ternary Operator

value = condition ? valueIfTrue : valueIfFalse`

Example:

cell.accessoryType = item.done == true ? .checkmark : .none

  1. Concurrency and Asynchronous Programming:
  • Swift Concurrency: With the introduction of async/await in Swift 5.5, handling asynchronous tasks has become more straightforward.
  • Combine: Apple's framework for handling asynchronous events with a declarative approach, which can be beneficial in networking scenarios

DispatchQueue

  • An object that manages the execution of tasks serially or concurrently on your app's main thread or on a background thread.
  • More on DispatchQueue

UI Element Positioning

Defining Structure

Snippet of Info:

1. IBOutlet - Interface Builder Outlet 
2. Who.What = Value
3. IBOutlet = Actions are from Code to Design
4. IBAction = Actions are from Design to Code 
5. Random Number = **Int.random(in: 0...5)** 
6. Random Element in an ``` Array = arrayVar.randomElement()
7. func myFunction(parameter: DataType) { ... } 

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published