【问题标题】:TWTRTwitter sessionStore now returns TWTRAuthSession: so how does one access the userName property now?TWTRTwitter sessionStore 现在返回 TWTRAuthSession: 那么现在如何访问 userName 属性呢?
【发布时间】:2018-06-10 18:59:38
【问题描述】:

使用 Swift 中的 TwitterKit 3.3.0 sharedInstance().sessionStore.session() 现在返回 TWTRAuthSession 而不是像以前一样的 TWTRSession。事情发生了变化,这很好,但是 the documentation 尚未更新以反映这一点,因此我不再知道如何访问以前的 TWTRSession 对象提供的 userName 属性。

【问题讨论】:

  • 我也是。这真的很奇怪,在 runtiem 看起来它仍然返回旧的 TWTRSession 类型。但是任何演员等都失败了。 TwitterKit 有一些质量问题......我想我毕竟必须回滚到以前的版本......
  • 顺便说一句,如果我打印出 [Any] 数组,它实际上仍然保存用户名和会话 cookie: ISSUE1084 会话为 [Any]: [ mynameblbla - 832523035788173312]
  • @Jonny 我喜欢“runtiem”的想法。听起来像是用剩菜做的越南菜。
  • 抛开烹饪问题不谈,用户名数据仍然存在于后面,但不知何故越南人设法向我们隐藏了它。

标签: ios swift twitterkit


【解决方案1】:

你可以用 perform(_:) 来做到这一点

希望下面的内容能帮助那些面临这个问题的人。

let username = session.perform(#selector(getter: TWTRSession.userName))?.takeRetainedValue() as? String

【讨论】:

  • 感谢您抽出宝贵时间回答@taka,我现在离这个项目太远了,我无法验证您的答案
猜你喜欢
  • 2013-08-20
  • 2014-06-19
  • 1970-01-01
  • 2019-12-25
  • 2021-10-04
  • 1970-01-01
  • 1970-01-01
  • 2016-11-07
  • 1970-01-01
相关资源
最近更新 更多