Hi Alex

Is it possible to please give us an example of passing refs from a singleton class used as a data cache back to the UI?

I am currently using the singleton pattern for caching my objects that aren't changed. I would like to be able to retrieve from my cache into say a UITableView then make some changes to the objects bound to the tableview, updating the cache at the same time.

Thanks
Liam

On 12/07/12 04:25, Alex White wrote:
I would do the same as Nic, singleton class that is available throughout the app, I use the class for all global settings like colours for the screens etc.

If you are going to pass data up as parameters and it is quite large it is worth looking at passing by ref rather than by value, also passing by ref allows the data changes to persist.

singleton example.

namespaceWizPR
{
publicsealedclassCore
{
public string DatabaseName {get;set;}

static readonly Core instance = new Core();

static Core () { }


Core() { }


public static Core Instance {
get { return instance;}
}
}
}

ATB

Alex

On 11 Jul 2012, at 17:14, Nic Wise wrote:

public static Dictionary<string, List<YourType>> TheCache = new ...

On a static class? eg YourType.Cache["foo"] could even do it, tho I'd say it'd be a bit better to put it in it's own class (YourTypeCache? Naming things is.... fun :) )


I usually feed things into views, or they talk to a central singleton class (eg for database access or to get a single client to talk to a REST service). those often cache for me, too - to save on the network calls.

On Wed, Jul 11, 2012 at 4:10 PM, Mike Murdock <[email protected] <mailto:[email protected]>> wrote:

    What the best ways to cache a generic list data between views.

    *Michael Murdock *
    /Software Engineer/

    (865) 482-1999 <tel:%28865%29%20482-1999>
    (865) 481-0921 <tel:%28865%29%20481-0921> fax
    www.allmeds.com <http://www.allmeds.com/>


    _______________________________________________
    MonoTouch mailing list
    [email protected] <mailto:[email protected]>
    http://lists.ximian.com/mailman/listinfo/monotouch




--
Nic Wise
t.  +44 7788 592 806 | @fastchicken | http://www.linkedin.com/in/nicwise
b. http://www.fastchicken.co.nz/

Earnest: Self-employed? Track your business expenses and income. http://earnestapp.com <http://earnestapp.com/> Nearest Bus: find when the next bus is coming to your stop. http://goo.gl/Vcz1p mobileAgent (for FreeAgent): get your accounts in your pocket. http://goo.gl/IuBU
Trip Wallet: Keep track of your budget on the go: http://goo.gl/ePhKa
London Bike App: Find the nearest Boris Bike, and get riding! http://goo.gl/Icp2

_______________________________________________
MonoTouch mailing list
[email protected] <mailto:[email protected]>
http://lists.ximian.com/mailman/listinfo/monotouch


_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to