문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top