×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    30

    Question Problem with descriptors

    I'm having a problem understanding how descriptors work

    Hi have the following class

    class User
    {
    public:
    User();

    /** Returns the nickname of the user */
    TDesC16 nickname() const;

    // TODO hacer esto privado con friend o factory
    void setNickname(const TDesC16 &nickname);

    private:
    TBuf16<40> m_nickname;
    };

    void User::setNickname(const TDesC16 &nickname)
    {
    m_nickname.Copy(nickname);
    }

    TDesC16 User::nickname() const
    {
    return m_nickname;
    }

    and from other code i do

    _LIT16(KNewItem, "ueueue");
    TBuf16<40> newItemBuf(KNewItem);

    User u;
    u.setNickname(newItemBuf);

    CEikonEnv::Static()->InfoWinL(u.nickname(), KNullDesC);

    The info window does not show "ueueue" as i would expect. Any help?

  2. #2
    Super Contributor
    Join Date
    Nov 2004
    Posts
    1,009

    Re: Problem with descriptors

    In the InfoWinL() function first parameter is the heading and second is the text that you want to show.

    try this: infowinl(_L("text"), u.nickname);

  3. #3
    Registered User
    Join Date
    Nov 2008
    Posts
    30

    Re: Problem with descriptors

    The problem was that the string appeared "corrupted", the first two letters were gone, changing it to

    TPtrC16 MVUser::nickname() const
    {
    return m_nickname;
    }

    made it work. Still wondering why :-/

  4. #4
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: Problem with descriptors

    this link might help you making you understand the basic concepts of descriptors http://descriptors.blogspot.com/

  5. #5
    Regular Contributor
    Join Date
    Apr 2008
    Posts
    146

    Re: Problem with descriptors

    Change TDesC16 nickname() const; to const TDesC16 & Nickname() const;

  6. #6
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,684

    Re: Problem with descriptors

    TDesC does not contain the data (it is an abstract base class), that is why. However returning const TDesC & (so a reference) would also work:
    Code:
    const TDesC16 & User::nickname() const
    {
    return m_nickname;
    }

  7. #7
    Nokia Developer Champion
    Join Date
    Jul 2004
    Posts
    2,015

    Re: Problem with descriptors

    P.S.

    If you're just using the name User for illustration purposes thats ok, but there is also a built in class called User.

Similar Threads

  1. Problem with CAknDoubleStyleListBox with a CAknSearchField
    By jjig in forum Symbian User Interface
    Replies: 2
    Last Post: 2009-09-17, 00:58
  2. Problem with eglSwapBuffers and heap corruption
    By greatape in forum Symbian Media (Closed)
    Replies: 2
    Last Post: 2007-05-24, 03:35
  3. netcards - Problem with opening adapter
    By kernj in forum Symbian Tools & SDKs
    Replies: 5
    Last Post: 2007-01-10, 08:56
  4. Problem: S60 SDK for CW in PC with .NET
    By anttij in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 1
    Last Post: 2005-02-28, 11:36

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×