Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]


How to access reference counting objects in object containers

The following code fragment retrieves a pointer to the reference counting object with the name "Monday". It assumes that such a reference counting object does exist.

...
class CMyobject : public CObject
    {
       ...
     };

_LIT(KMatcher,"Monday");
...
CMyobject*  theobject;
CObjectCon* thecontainer;
TInt        thefindhandle;
TName       objname;
...
thecontainer->FindByName(thefindhandle,KMatcher,objname);
theobject = (CMyObject*)thecontainer->AtL(thefindhandle);
...

The following code fragment retrieves pointers to all of the reference counting objects whose names end with "day":

...
class CMyobject : public CObject
    {
       ...
       };

_LIT(KMatcher,"*day");
...
CMyobject*  theobject;
CObjectCon* thecontainer;
TInt        thefindhandle;
TName       objname;
...
thefindhandle = 0;
while (thecontainer->FindByName(thefindhandle,KMatcher,objname)==KerrNone)
    {
    // objname contains the reference counting object's
    // name, e.g. "Monday" or "Tuesday"
    ...
    theobject = (CMyobject*)thecontainer->AtL(thefindhandle);
    ...
    }
// Now found all matching reference counting objects
...