Objective C: is Posing available for ios?

后端 未结 2 453
星月不相逢
星月不相逢 2021-01-03 16:04
  1. I am trying to implement posing for one ios project.
  2. The scenario: Defining class of controller at run time
  3. I realise that poseAsClass or class_poseA
相关标签:
2条回答
  • 2021-01-03 16:41

    You should look into Method Swizzling. It helps you change the functions/function bodies at run time.

    There is a great tutorial here.

    0 讨论(0)
  • 2021-01-03 16:47

    The whole pose / swizzle approach is really useful if you want to tamper with the OS / private SDK supplied classes - but you generally shouldn't be doing that and it's not a good idea to use it as a standard approach in your own code.

    The scenario: Defining class of controller at run time

    You would usually do this by using an abstract superclass / interface / @protocol to define the interface that your potential controllers need to implement and then switching them in and out at runtime.

    In your case it seems that you would have one controller which acts as a proxy for the true controller. You also don't technically need an @protocol because UITableViewController is effectively your abstract superclass, but it would be best for your proxy to be a UITableViewController and own the view and for your other controllers to be NSObject subclasses and simply conform to the UITableView DataSource/Delegate protocols.

    0 讨论(0)
提交回复
热议问题