//
//  UIViewController+Extension.swift
//  MyTatvaCare
//
//  Created by Nirav Ramani on 07/05/25.
//

import Foundation
import UIKit

extension UIViewController {
    static func instantiate(fromStoryboard name: String) -> Self {
        return instantiateViewController(fromStoryboard: name)
    }

    private static func instantiateViewController<T: UIViewController>(fromStoryboard name: String) -> T {
        let storyboard = UIStoryboard(name: name, bundle: nil)
        let identifier = String(describing: self)
        guard let viewController = storyboard.instantiateViewController(withIdentifier: identifier) as? T else {
            fatalError("ViewController with identifier \(identifier) not found in \(name) storyboard.")
        }
        return viewController
    }
}
