1
votes
-(id)init
{
if (self = [super init]) 
{
    self.dmrPlaylists = [[[NSMutableArray alloc] initWithCapacity:0] autorelease];
     }
}
-(void)dealloc
{   
[self.dmrPlaylists release];
}
-(DMRPlaylist *)getDMRPlaylistByUUID:(NSString *)deviceUUID
{
if (deviceUUID == nil)
    return nil;

for(int i = 0; i < self.dmrPlaylists.count; i++)
{
    DMRPlaylist * dmrPlaylist = [self.dmrPlaylists objectAtIndex:i];
    if([dmrPlaylist.deviceUUID isEqualToString:deviceUUID])
    {
        return dmrPlaylist;
    }
}

return nil;
}

Memory(Core Foundation/Object-C) Incorrect decrement of the reference count of an object that is not owned at this point by the caller.

Thanks in advance.

2
....which line? Also, how is your dmrPlaylists property declared? - borrrden
@property (nonatomic, retain) NSMutableArray * dmrPlaylists; yes ,the warning on[self.dmrPlaylists release]; -(void)dealloc { //[self.dmrPlaylists release]; [delegateList release]; free(_dmrStateChangeNotifier); [super dealloc]; } - HamasN

2 Answers

1
votes

1) Do not use self.dmrPlaylists in your init and dealloc methods. Instead, interact with the underlying variable.

2) Call [super dealloc]

Without knowing which line the warning is on, can't be sure, but these are problems.

0
votes

You haven't told us what part of the above code causes the error. Step through it with the debugger to isolate where it happens and get back to us.

Also, you haven't given us enough code to know what's wrong. For example:

self.dmrPlaylists = [[[NSMutableArray alloc] initWithCapacity:0] autorelease];

probably ultimately calls -setDmrPlaylists: with an autoreleased mutable array. Where is -setDmrPlaylists: defined? Is it declared by a @property statement and @synthesizeed? If so, is it declared as a retain property? If not, then the setter will never call retain on the mutable array. And when the autorelease decrements the mutable array's retain count at the end of the event loop, it will likely be deallocated leaving you pointing at junk memory.