×
Namespaces

Variants
Actions
Revision as of 19:46, 28 July 2009 by lpvalente (Talk | contribs)

Archived:Accessing data anywhere in application

From Nokia Developer Wiki
Jump to: navigation, search

In many situations, it is useful to have a method or a way to place data somewhere that could be accessed globally in the application. One of those ways is placing the global data in the Document class.

The Document class is the most appropriate place to keep the data which needs to be accessed from the whole application, according to the Document/View architecture. A global reference to the Document class instance if accessible through the AppUi's method Document(). This method has the following signature:

CEikDocument *Document() const;

This means that we should perform a cast on the result value to match our actual Document class, defined in the application. Now, here's how to access your Document instance:

#include <eikappui.h>
 
// suppose your Document class is named as 'MyDocument'
 
MyDocument* doc = static_cast <MyDocument*> (CEikonEnv::Static()->EikAppUi()->Document() );
 
// now access your data
doc->myData = ... ;
54 page views in the last 30 days.