GithubHelp home page GithubHelp logo

Comments (7)

AliSoftware avatar AliSoftware commented on July 20, 2024 6

Mmmh could be a very simple addition to do indeed. Care to do a Pull Request?

I think it should be as easy as adding something similar to:

protocol NIBBased {
  static var nibName: String { get }
}

extension NIBBased {
  static var nibName: String {
    return String(describing: self), bundle: )
  }
}

extension NIBBased where Self: UIViewController {
  static func instantiate() -> Self {
    return Self.init(nibName: self.nibName, bundle: Bundle(for: self))
  }
}

… + documentation and tests πŸ˜‰
Would be a great contribution :)

from reusable.

AliSoftware avatar AliSoftware commented on July 20, 2024 1

Nope, I don't think anyone has found the time to implement that yet indeed πŸ˜…

from reusable.

codwam avatar codwam commented on July 20, 2024

Yep, closed any time.

from reusable.

Pomanks avatar Pomanks commented on July 20, 2024

Has this feature been implemented yet? It doesn't seem like.

from reusable.

felipedemetrius avatar felipedemetrius commented on July 20, 2024

Hi @AliSoftware ,

I believe this issue is resolved in pull request #82

from reusable.

AliSoftware avatar AliSoftware commented on July 20, 2024

Should be once merged indeed, thanks for the PR πŸ‘ just took a look and commented there πŸ™‚

from reusable.

AliSoftware avatar AliSoftware commented on July 20, 2024

Just realized that all this functionality is already handled for us by Apple: when you call init on a UIViewController, it forwards it to the designated init(nibName:bundle:) with nil parameters… and when nibName is nil, iOS automatically searches for a XIB of the same name as the class and use it if it finds one!

This is detailed here in Apple's documentation. See also #82 (review)

That means that given a class CustomViewController: UIViewController { … } if you also have a CustomViewController.xib file in your bundle then using let vc = CustomViewController() will automatically use the XIB for loading the VC without yo needing to specify anything.

Hence I'm gonna close this issue since… there's no need for Reusable here, this is behavior provided by iOS for UIViewControllers already πŸ˜‰

from reusable.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.