基于JSON对象的数据结构

发布于 2024-12-13 16:58:49 字数 255 浏览 3 评论 0原文

我刚刚有一个基于 MVC 模型的问题,我想将其用于 JSON 对象。我正在解析来自 Web 服务的一些值,此时,出于安全目的,我不想在任何给定点在设备上存储任何凭据。拥有许多可以访问有关该对象的信息的视图控制器,将此对象作为可以全局访问并且只有一个实例的“单例对象”,而不是在每个视图控制器上重新创建该对象,是一种好方法吗?另外,假设我想创建某种关于 json 对象的模型,将 json 中的对象绑定到此类“模型”的更好方法是什么?有没有通用的方法或者只是“DIY”方法?

谢谢。

I just had a question based on MVC model, which I want to utilize with respect to JSON object. I am parsing some values from web services, and at this point, I don't want to store any credentials on the device at any given point for security purposes. Having many views controllers which can access the information with respect to this object, is it a good approach to have this object as a "singleton object" which can be globally accessed and have only one instance, than recreating the object at every viewcontroller. Also, lets say I want to create some sort of model with respect to the json object, what would be a better way to bind the objects from json to such "model"? Is there any universal way to d it or rather just "DIY" approach?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笨笨の傻瓜 2024-12-20 16:58:49

在第一种情况下,您可以使用单例对象来存储您的凭据。许多人只是将这些信息存储在 appDelegate 中,它充当大多数应用程序的中央仓库。就 JSON 建模而言,如果您使用类似以下内容:
json-framework,它将您的数据转换为 Objective-C 结构,例如 NSArray< /code>s 和 NSDictionarys,它们对应于它获取的 JSON 结构。

In the first case, you can use a singleton object to store your credentials. Many people just store this information in the appDelegate, which serves as a kind of central warehouse to most apps. As far as the JSON modeling, if you use something like:
json-framework, it will convert your data to Objective-C structures, like NSArrays and NSDictionarys, which correspond to the JSON structures it gets.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文