NSMutableDictionary issue

Discussion in 'iOS Development' started by johnmabassa, Jun 21, 2009.

  1. johnmabassa

    johnmabassa Member

    Joined:
    Mar 16, 2009
    Messages:
    87
    Likes Received:
    0
    Hi,

    I am having a code like this in my implementation


    Code:
    NSMutableDictionary *dict=[NSMutableDictionary dictionary];
    Now I am trying to do this

    Code:
     dict = [serviceUtils GetData];
    GetData is a function which returns another NSMutableDictionary, I am getting the values there but it is showing a memory leak, is there any issue with the above statement?

    -John
  2. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    make sure that -getData is returning an autoreleased object; that is the correct way to do it.

    Code:
    - (NSMutableDictionary *)getData {
             NSMutableDictionary *returnDict = ...;
       
             // Some work to make dict as needed.
    
             return [returnDict autorelease];
    }

Share This Page