我是 Objective C 新手,正在学习使用 RubyMotion 构建应用程序。
我希望能够调用 current_user 并让当前登录的用户访问我的应用。
现在我正在从服务器发送 current_user 记录并在用户登录时调用 User.new(:user) ,但我不能像我那样在全局范围内调用这个用户喜欢,并将其发送到 Formotion 编辑表单等
现在我正在使用 KVO 初始化模型,如 ruby tutorial 中所述我应该实现 MotionModel 吗?我将如何使用该工具来获取现成的 current_user 方法?
谢谢!
最佳答案
我通常在用户模型中使用类方法。
User.current_user
您的用户类别:
class User
def self.current_user
@current_user ||= begin
# get your user here, using BubbleWrap's App::Persistence or another persistence mechanism.
end
end
end
关于ios - 在 RubyMotion 应用程序中实现类似 "current_user"的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19202689/