1
votes

i have 3 classes in this application.

Memory leak is happened in DetailBrand2.m , DetailBrand2 inherited from DetailType, Also i have a wrapper class , FairPriceDatabaseView, which communicate with sqlite3.

I have confused with NSDictionary, NSString and Sqlite?

The leak is happened in this line!!!?

NSDictionary * brandRow = [fairPrice_DB getProductRow:tempProductID];

NSString *message = [brandRow objectForKey:@"brandName"];

brandRow = nil;

I have just started within iphone appmication, i appreciate in advance for any help, i have read many iphone memory management guide but i can not solve it. The issue is that i have not used any of keywords look like alloc, retain, copy or mutablecopy but i have leak in this line!!

This line bring back an NSDictionary which contains productID,productName,brandName,price. from wrapper class, fairPrice_DB is an instanse of FairPriceDatabaseView.

DetailBrand2.h

@interface DetailBrand2 : DetailType
{
    NSString * topBrandName;
    NSNumber * tempProductID;
    NSString * brandName;
}
@property (nonatomic, retain) NSString * topBrandName;
@property (nonatomic, retain) NSString * brandName;
@property (nonatomic, retain) NSNumber * tempProductID;

-(void) loadbrandName;

@end

DetailBrand2.m

#import "DetailBrand2.h"
#import "SeventhFairPriceAppDelegate.h"

@implementation DetailBrand2

@synthesize topBrandName,brandName,tempProductID;

-(void) loadbrandName
{
    if(!topBrandName)
    {
        [self loadDB];
        *NSDictionary * brandRow = [fairPrice_DB getProductRow:tempProductID];*
        NSString *message = [brandRow objectForKey:@"brandName"];
        brandRow = nil;
        self.topBrandName = message;
//        self.brandName =  self.topBrandName;
    }
}
1

1 Answers

0
votes

The Problem is solved by overwriting dealloc method :D

DetailBrands.m

 -(void) dealloc
    {
          [self.tempProductID release];
          [self.topBrandName release];
          [self.brandName release];
          [super dealloc];
    }