目标C:是否可用于ios? [英] Objective C: is Posing available for ios?

查看:96
本文介绍了目标C:是否可用于ios?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  1. 我正在尝试为一个ios项目实施冒充。

  2. 场景:
    在运行时定义控制器类

  3. 我意识到poseAsClass或class_poseAs是不适用于ios
    &也不赞成使用macOX。

  4. 将会感谢任何在ios中实施冒充的指示。谢谢

  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_poseAs is not available for ios & also deprecated for macOX.
  4. will be grateful to any directions to implement posing in ios. Thanks


推荐答案

如果你想篡改整个姿势/混合方法真的很有用OS /私有SDK提供的类 - 但是你通常不应该这样做,并且在你自己的代码中将它用作标准方法并不是一个好主意。

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

通常使用抽象超类/来执行此操作interface / @protocol定义潜在控制器需要实现的接口,然后在运行时切换它们。

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.

在你的情况下,似乎你有一个控制器充当真正控制器的代理。你在技术上也不需要@protocol,因为 UITableViewController 实际上是你的抽象超类,但你的代理最好是 UITableViewController 并拥有该视图,并且您的其他控制器为 NSObject 子类并且只需符合 UITableView DataSource / Delegate 协议。

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.

这篇关于目标C:是否可用于ios?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆