I am currently writing a multi-user social iPhone app that interfaces with a server.
I have a user class, which stores all the normal data about each user (name, id, etc.). However, where I am running fast, it is how well these users have to store.
Currently, I have a singleton called "UserManager", which stores an array of users in the app (the initial launch downloaded from the server prompted you to input some basic details ), As well as a separate user object to isolate the actual existing user of the app. The user list needs access to many different parts of the app, which includes a map that shows where they are (if they choose to disclose it), to enable them to send messages to other users. , e.t.c.
To be completely honest, the singleton solution does not fit right with me. I've always heard Siglaton to avoid it wherever possible, though, what's better for using it, its I know about
I only have a very basic understanding of design patterns, although obviously I know that its essential requirement is not a terrible idea.
So I came here to ask you good people in a way to store such data! I do not necessarily mean only the iPhone, this is a big problem. You are on the right track that you Some types of data controllers want objects that will handle your user data objects from you. You can create this object singleton, or you can not optionally instantify your application controller (App Representative) to the Data Controller, and it is given to view controllers on each of their windows or launch time is. One advantage is that it will be easy to modify your data for many data controllers; This is not important for an iPhone app, but it could be a problem for a desktop app, in which multiple document windows could be opened at once. On the other hand, a singleton might be easy for code and prevent insects on the road. You can find the last few paragraphs on interesting, it does talk about separating the model controller / visual controller roles.
Comments
Post a Comment