Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- i have a question about how to structure my stuff. in my app, which is going to download a set of documents from a json service, i have a control sequence i'm trying to implement. It's a bit long, so i'll write it in a new line, but please let me know if i shold do anything differently.
- I have an initial screen with a login prompt. I had statically written the authentication method in this, and it works, but i need a way of checking if a session is valid throughout my app, so i moved the login method to controllers/AuthenticationController.m, alongside other utility methods such as checkIfSessionIsValid.
- I also created a generic document controller, DocumentController, which handles json requests in order to populate an array of Document objects, defined in classes/Document.m.
- My challenge is the following:
- In any arbitrary view controller i need to check for a valid session before carrying out any json requests. I have set this up in my api to return a simple "valid" true/false json object if the server side session has epire. If this returns false, i need to nil the document array, user login information, and return to the login screen.
- This is how i imagined implementing it, but i'm not sure if it's the way to go.
- 1. Have every view controller import the authentication controller
- 2. prompt the authentication controller [auth isSessionValid]
- 3. if true, carry on with the json request, if false, do a programatic segue to the login screen, and in prepareforsegue on this operation nil out all user loaded info.
- Assuming this is is the way to do it, here are some of the problems i have
- 1. I don't have a segue from every view controller to my login screen - how can i get there without one?
- 2. I use ASIHTTPRequest, which does an async request, and afaik the way you handle a response is by doing soemthing like this: [request setDidFinishSelector:@selector(pareseSessionValidity:)]; I don't know how to get a return value from this (it's async btw), so the view controller can get a return value.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement