Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6985683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:42:41+00:00 2026-05-27T18:42:41+00:00

Please help me I am not able to understand why this is happening there

  • 0

Please help me I am not able to understand why this is happening there a object _getProductType is deallocate without any reason. please take a look, I am not able to figure out what is happening , if you can help me I will be very thank full to you, Thanks in advance

    //
    //  ProductComponentViewController.m
    //  TurfNutritionTool
    //
    //  Created by Aashish Joshi on 10/14/11.
    //  Copyright 2011 Abacus Consultancy Services. All rights reserved.
    //

    #import "ProductComponentViewController.h"
    #import <QuartzCore/QuartzCore.h>

    @implementation ProductComponentViewController

    @synthesize productTableView =      _productTableView;
    @synthesize productTypeSelector =   _productTypeSelector;
    @synthesize turftypePopover =       _turftypePopover;
    @synthesize gotTurftype =           _gotTurftype;
    @synthesize resultProduct =         _resultProduct;
    @synthesize productTableCellStyle = _productTableCellStyle;
    @synthesize dbObject =              _dbObject;
    @synthesize getProductType =        _getProductType;

    #define Granular @"G"
    #define Liquid @"L"
    #define Tankmix @"T"
    #define AllProduct @"A"

    - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
       {
        self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
        if (self) {
            // Custom initialization
        }
        return self;
       }

         - (void)didReceiveMemoryWarning
         {
        // Releases the view if it doesn't have a superview.
        [super didReceiveMemoryWarning];

       // Release any cached data, images, etc that aren't in use.
       }

    #pragma mark - View lifecycle

       - (void)viewDidLoad
       {
        [super viewDidLoad];
        // D    o any additional setup after loading the view from its nib.

        UIColor *_background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"main_bg.png"]];
        self.view.backgroundColor = _background;
        [_background release];

        // init the segment button value 
        [productTypeSelector setSelectedSegmentIndex:0];

        _getProductType = [[NSString alloc] initWithString:AllProduct];

        // set table delegate
        _productTableView.delegate = self;

        // load the product
        [self loadProductComponentValues];

        // Set the table view to be rounded
        [[_productTableView layer] setCornerRadius:5.0];
    }

    - (void)viewDidUnload
    {
        [self setProductTableView:nil];
        [self setProductTypeSelector:nil];

        _productTableView = nil;
        _productTypeSelector = nil;
        _turftypePopover = nil;
        _gotTurftype = nil;
        _resultProduct = nil;
        _productTableCellStyle = nil;
        _getProductType = nil;

        [_getProductType release];
        [_productTableView release];
        [_productTypeSelector release];
        [_turftypePopover release];
        [_gotTurftype release];
        [_resultProduct release];
        [_productTableCellStyle release];

        [super viewDidUnload];
        // Release any retained subviews of the main view.
        // e.g. self.myOutlet = nil;
    }

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        // Return YES for supported orientations
        return YES;
    }

    - (void)dealloc {

        [_getProductType release];
        [_productTableView release];
        [_productTypeSelector release];
        [_turftypePopover release];
        [_gotTurftype release];
        [_resultProduct release];
        [_productTableCellStyle release];    

        [super dealloc];
    }

    #pragma mark - Table view data source

    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
    {
        // #warning Potentially incomplete method implementation.
        // Return the number of sections.
        return 1;
    }

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {
        // #warning Incomplete method implementation.
    // Return the number of rows in the section.

    // NSLog(@"%s", __FUNCTION__);
    return [self.resultProduct count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {

        [[NSBundle mainBundle] loadNibNamed:@"productContentTableCellStyle" owner:self options:nil];
        cell = _productTableCellStyle;
        self.productTableCellStyle = nil;
    }


    NSDictionary * _productRow = [_dbObject getProductdetail:[self.resultProduct objectAtIndex:indexPath.row]];


    // Configure the cell...

    UILabel* _label = (UILabel *)[cell viewWithTag:1];
    NSString* _linkcode = [_productRow objectForKey:@"linkcode"];  
    _label.text = _linkcode;

    _label = (UILabel *)[cell viewWithTag:2];
    NSString* _description = [_productRow objectForKey:@"description"];
    _label.text = _description;

    _label = (UILabel *)[cell viewWithTag:3];
    NSString* _productcode = [_productRow objectForKey:@"productcode"];
    _label.text = _productcode;

    _label = (UILabel *)[cell viewWithTag:4];
    NSString* _weight = [_productRow objectForKey:@"weight"];
    _label.text = _weight;

    _label = (UILabel *)[cell viewWithTag:6];
     NSNumber* _costperBag = [[NSNumber alloc] initWithFloat:[[_dbObject getUserProductCost:[self.resultProduct objectAtIndex:indexPath.row]] floatValue]];
    _label.text = [@"$ " stringByAppendingString:[_costperBag stringValue]];
    [_costperBag autorelease];


    _getProductType = [_productRow objectForKey:@"producttype"];

    if ([_getProductType isEqualToString:@"G"]) {

        _label = (UILabel *)[cell viewWithTag:10];
        NSString* _weightTag = [[NSString alloc] initWithString:@"Weight in Lbs"];  
        _label.text = _weightTag;
        [_weightTag autorelease];

        _label = (UILabel *)[cell viewWithTag:11];
        NSString* _SGNTag = [[NSString alloc] initWithString:@"SGN"];  
        _label.text = _SGNTag;
        [_SGNTag autorelease];

        _label = (UILabel *)[cell viewWithTag:5];
        NSString* _sgn = [_productRow objectForKey:@"sgn"];
        _label.text = _sgn;

} else if([_getProductType isEqualToString:@"L"]) {

        _label = (UILabel *)[cell viewWithTag:10];
        NSString* _weightTag = [[NSString alloc] initWithString:@"Weight in Ozs"];  
        _label.text = _weightTag;
        [_weightTag autorelease];

        _label = (UILabel *)[cell viewWithTag:11];
        NSString* _SGTag = [[NSString alloc] initWithString:@"SG"];
        _label.text = _SGTag;
        [_SGTag autorelease];


        _label = (UILabel *)[cell viewWithTag:5];
        NSString* _sgn = [_productRow objectForKey:@"sg"];
        _label.text = _sgn;

    } else if([_getProductType isEqualToString:@"T"]) {

         _label = (UILabel *)[cell viewWithTag:10];
         NSString* _weightTag = [[NSString alloc] initWithString:@"Weight in Ozs"];  
        _label.text = _weightTag;
        [_weightTag autorelease];

        _label = (UILabel *)[cell viewWithTag:11];
         NSString* _SGTag = [[NSString alloc] initWithString:@"SG"];
        _label.text = _SGTag;
        [_SGTag autorelease];    

        _label = (UILabel *)[cell viewWithTag:5];
        NSString* _sgn = [_productRow objectForKey:@"sg "];
        _label.text = _sgn;
    }
    return cell;
}

- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { 

    UIColor *_background = [[[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"toolbar_bkg.png"]] autorelease];
    UIView* _customView = [[[UIView alloc]initWithFrame:CGRectMake(10.0, 0.0, 300.0, 44.0)]autorelease];
    _customView.backgroundColor = _background;
    return _customView; 
}

- (UIView *) tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { 

    UIColor *_background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"toolbar_bkg.png"]];
    UIView* _customView = [[[UIView alloc]initWithFrame:CGRectMake(10.0, 0.0, 300.0, 44.0)]autorelease];
    _customView.backgroundColor = _background;
    [_background release];
    return _customView ;    
}

#pragma mark - Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Navigation logic may go here. Create and push another view controller.
    /*
     <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
     // ...
     // Pass the selected object to the new view controller.
     [self.navigationController pushViewController:detailViewController animated:YES];
     [detailViewController release];

    if (_delegate != nil) {
        NSString *_selectedTurftype = [_getTurftype objectAtIndex:indexPath.row];
        [_delegate getSelectedTurftype:_selectedTurftype];
    }
     */
    // NSDictionary * _productRow = [_dbObject getProductdetail:[self.resultProduct objectAtIndex:indexPath.row]];

    // Animate the deselection
    [self.productTableView deselectRowAtIndexPath:[self.productTableView indexPathForSelectedRow] animated:YES];

    CGRect _popoverRect = CGRectMake(800.0f, 380.0f, 10.0f, 10.0f);

    if ([_turftypePopover isPopoverVisible]) {
        [_turftypePopover dismissPopoverAnimated:YES];
    }
    else
    {
        ProductDetailViewController* _productDetailViewControllerObj = [[ProductDetailViewController alloc] init];
        _turftypePopover = [[UIPopoverController alloc]
                            initWithContentViewController:_productDetailViewControllerObj];
        _productDetailViewControllerObj.dbObject = _dbObject;

        [_productDetailViewControllerObj getSelectedProductId:[self.resultProduct objectAtIndex:indexPath.row] ];
        [_productDetailViewControllerObj release];
        _turftypePopover.popoverContentSize = CGSizeMake(360, 500);
        [_turftypePopover presentPopoverFromRect:_popoverRect inView:self.view 
                        permittedArrowDirections:0 animated:YES];
    }

    [self.productTableView deselectRowAtIndexPath:[self.productTableView indexPathForSelectedRow] animated:YES];
}

#pragma mark - ProductComponentViewController lifecycle methods

- (IBAction)laodTurftype:(id)sender {

    [self initAllTheProduct];

    if (_getProductType == (id)[NSNull null] && _getProductType == nil) {

        _getProductType = [NSString stringWithString:AllProduct];
    }

    if ([_turftypePopover isPopoverVisible]) {
        [_turftypePopover dismissPopoverAnimated:YES];
    }
    else
    {
        TurftypePopoverViewController* _turftypeControllerObj = [[TurftypePopoverViewController alloc] init];

        _turftypeControllerObj.dbObject = _dbObject;

        _turftypeControllerObj.delegate = self;

        _turftypePopover = [[UIPopoverController alloc]
                            initWithContentViewController:_turftypeControllerObj];
        [_turftypeControllerObj release];

        _turftypePopover.popoverContentSize = CGSizeMake(150, 225);
        [_turftypePopover presentPopoverFromBarButtonItem:sender
                                 permittedArrowDirections:UIPopoverArrowDirectionAny
                                                 animated:YES];
    }
}

- (IBAction)setProductType:(id)sender {

     switch (_productTypeSelector.selectedSegmentIndex) {
         case 0:
             _getProductType =  [NSString stringWithString:AllProduct];
             break;
         case 1:
             _getProductType = [NSString stringWithString:Granular];
             break;   
         case 2:
             _getProductType = [NSString stringWithString:Liquid];
             break; 
         case 3:
             _getProductType = [NSString stringWithString:Tankmix];
             break; 
     }

    [self loadProductComponentValues];
    // Check Point
    [TestFlight passCheckpoint:@"SET_PRODUCT_TYPE"];
}

// This is Delgate Method to get selceted product
-(void) getSelectedTurftype:(NSString*) getTurftype {

    self.gotTurftype = getTurftype;
    NSLog(@"self.gotTurftype %@", self.gotTurftype);
    [self loadProductComponentValues];

    if ([_turftypePopover isPopoverVisible]) {
        [_turftypePopover dismissPopoverAnimated:YES];
    }
}

-(void) initAllTheProduct {

    _getProductType = [NSString stringWithString:AllProduct];
    self.gotTurftype = nil;

    // init the segment button value 
    [productTypeSelector setSelectedSegmentIndex:0];
    [self loadProductComponentValues];
    // Check Point
    [TestFlight passCheckpoint:@"SET_ALL_PRODUCT"];
}

- (IBAction)setAllProduct:(id)sender {

    [self initAllTheProduct];
}

// This Method use for Load Value of ProductComponent
- (NSMutableArray*) loadProductComponentValues {

    [self.resultProduct removeAllObjects]; 
    if (!_dbObject) [self loadDBAccessDatabase];

    self.resultProduct = [[NSMutableArray alloc] initWithArray:[self.dbObject getRelatedProductArray:self.gotTurftype andProductType:_getProductType]];
    [_productTableView reloadData];
    return self.resultProduct;
}

- (NSMutableArray *) loadProductComponentValuesIfEmpty {
    // NSLog(@"%s", __FUNCTION__);

    [self initAllTheProduct];
    if (!_dbObject) [self loadDBAccessDatabase];
    if (!self.resultProduct || ![self.resultProduct count]) self.resultProduct = [[NSMutableArray alloc] initWithArray:[self.dbObject getRelatedProductArray:self.gotTurftype andProductType:_getProductType]];
    // Check Point
    [TestFlight passCheckpoint:@"LOAD_DATABASE"];

    return self.resultProduct;
}

- (DBAccess *) loadDBAccessDatabase {
    // NSLog(@"%s", __FUNCTION__);
    if (!_dbObject) {

        NSString * _dbFileName = @"turfnutritiontool.db";
        _dbObject = [[DBAccess alloc] initWithSSDBAccessFilename:_dbFileName];
    }
    return _dbObject;
}

@end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T18:42:41+00:00Added an answer on May 27, 2026 at 6:42 pm

    use:
    self._getProductType = [[NSString alloc] initWithString:AllProduct];

    change this sequence:

        [_getProductType release];
        [_productTableView release];
        [_productTypeSelector release];
        [_turftypePopover release];
        [_gotTurftype release];
        [_resultProduct release];
        [_productTableCellStyle release];
    
       _productTableView = nil;
        _productTypeSelector = nil;
        _turftypePopover = nil;
        _gotTurftype = nil;
        _resultProduct = nil;
        _productTableCellStyle = nil;
        _getProductType = nil;
    

    you were leaking memory as setting pointers to nil, //memory leak
    first you should release then set pointers to nil;// no leak

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

please help not able to understand this concept. Thanks
can you please help me with this issue the String class does not have
I know I'm not asking this quite right, either. Please help me better form
Please help us settle the controversy of Nearly everything is an object ( an
Please help me convert this line to C#. objManagementBaseObject.SetPropertyValue(hDefKey, CType(&H & Hex(RegistryHive.LocalMachine), Long)) Related
Please help me understand how the process goes. I understand that web browsers contain
I've seen this behaviour in many websites and web applications but I'm not able
please help me solve this issue. I have a client using WCF. I don't
I am getting very strange errors and i am not able to understand what
Please help! I'm really at my wits' end. My program is a little personal

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.