Life cycle of iOS App and Controller - Imtiaz211/interviews GitHub Wiki

Explain View Controller Lifecycle events order

LoadView - Creates the view that the controller manages. It’s only called when the view controller is created and only when done programmatically. viewDidLoad - Called after the controller’s view is loaded into memory. It’s only once called when the view is created. viewDidAppear - Notifies the view controller that its view was added to a view hierarchy. viewWillAppear - it’s called whenever the view is presented on the screen. In this step the view has bounds defined but the orientation is not applied. viewWillLayoutSubviews - Called to notify the view controller that its view is about to layout its subview. This method is called every time the frame changes. viewDidLayoutSubviews - Called to notify the view controller that its view has just laid out its subviews. Make additional changes here after the view lays out its subviews. viewWillDisappear - Before the transition to the next view controller happens and the origin view controller gets removed from screen, this method gets called. viewDidDisappear - After a view controller gets removed from the screen, this method gets called. You usually override this method to stop tasks that should not run while a view controller is not on screen.

What are the most important application delegate methods a developer should handle

  1. application: willFinishLaunchingWithOptions.
  2. applicationDidBecomeActive
  3. applicationWillResignActive
  4. applicationDidEnterBackground
  5. applicationWillEnterForeground
  6. applicationWillTerminate

ios App State

  1. Not Running = This means the app has not launched yet, Or the app has been terminated by the user.
  2. Inactive = This state occurs while the app transitioning to the Active state or transitioning from the Active state on the foreground.
  3. Active = The app is running on foreground and the UI is accessible.
  4. Background = Once the app moved to background it will be transited to the Background state.
  5. Suspended = This is the app state when your app is on background after the app has been transited from the background state by the OS. At this app state, your app remains on the memory. But not executing any code.

SSDLC (Secure Software Development Life Cycle)

  1. Shift mindsets toward DevSecOps.
  2. Keep security requirements current.
  3. Take advantage of threat modeling.
  4. Establish secure design requirements.
  5. Use open source components… securely.
  6. Implement code reviews.
  7. Perform penetration testing.
  8. Manage potential vulnerabilities.
  9. Prepare a standard incident response.
  10. Setting up a security champions program.

Boost your swift code performance

  1. Background, Thread
  2. Set optimization level in build setting - optimization for speed
  3. Use final and private for method acces.
  4. Avoid print in release build
  5. Inline your code, means small function,
  6. withUnsafeBufferPointer for array itteration.
  7. Use value type not Reference type
  8. limit protocol to classs only if you know.
  9. Contiguous Array

Debouncing

not to call API Frequently while searching from textfield.