Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Some advice re. "saving" a variable so it is accessible to all classes/methods



On Mon, Jun 30, 2008 at 9:46 AM, Michael Kaye <email@hidden> wrote:
> So my question (finally) is where do I store the sessionid variable so it is
> accessible through out all classes and for as long as the app is running?
>
> My current approach is to save the value in an Extern NSString but I'm not
> convinced this is correct. I feel like the class that handles the login
> ought to maintain it some how, but if so how do I keep it alive and
> accessible after I release the login class object?
>
> I hope makes some sense and hopefully someone can provide me with a few
> pointers.

I don't see that the login object needs to be released at all.

Logically, the login object is the one responsible for obtaining the
session id, so it "owns" the session id. Maybe have the login object
be a singleton, so you can always access the instance, and give it an
accessor for the session id. Conceptually, think of the singleton
login object as "authentication to the server". It can give an opaque
certificate of authentication, in the form of the session id.

Owen
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden

References: 
 >Some advice re. "saving" a variable so it is accessible to all classes/methods (From: Michael Kaye <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.