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 6237305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:00:16+00:00 2026-05-24T11:00:16+00:00

I’m using Leaks, and I believe I’ve narrowed down the problem, and I’m sure

  • 0

I’m using Leaks, and I believe I’ve narrowed down the problem, and I’m sure my inexperience has something to do with it. If you see a failure in my logic (as in, there’s obviously a simpler way to do this), please let me know.

In this case we’re working with 3 classes, a Row class that describes rows in a database, a Database class that contains getRow, insertRow type functions, and a ViewController class.

inside Row.h:

@interface Row : NSObject {
int rowID;
NSString *FirstName;
NSString *LastName;

}

@property (nonatomic) int rowID;
@property (nonatomic, retain) NSString *FirstName; <--see comments below
@property (nonatomic, retain) NSString *LastName; <--see comments below

@end

Hopefully this one is pretty obvious, creates an object that i’m going to push data I pull from the database into.

inside Database.m

-(Row *) getRow {
NSLog(@"Inside getRow");
Row *holder = [[[Row alloc] init] autorelease];

...All the SQL stuff... (Select * from table where id = 1), etc.


char *first = (char *)sqlite3_column_text(statement, 1);
char *last = (char *)sqlite3_column_text(statement, 2);

holder.rowID = sqlite3_column_int(statement, 0);
holder.FirstName = [NSString stringWithUTF8String:first];
holder.LastName = [NSString stringWithUTF8String:last];

return holder;
}

Also, hopefully, fairly self explanatory. Get a specific row from the database, put the info into a Row object (see Row.h).

inside ViewController.m

-(void) viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];

    dataB = [[Database alloc] init];
    [dataB openDB];

    currentRow = [[dataB getRow] retain]; <--See comments below.

    firstNameLabel.text = currentRow.FirstName;

}

-(IBAction)btnGetLastName:(id)sender{
lastNameLabel.text = currentRow.LastName; <--See comments below.
[currentRow release];
currentRow = [dataB getRow];
}

Basically here the view controller give you the first name, and when you click on a button it displays the last name.

So, I’m leaking, and I’ve narrowed it down to every time I press btnGetLastName. If I don’t retain

currentRow = [[dataB getRow] retain]; 

I crash at

lastNameLabel.text = currentRow.LastName; 

(Message sent to deallocated instance).

I’ve been banging my head into the wall for a couple days on this and I would really like to move forward from here, so if anyone can offer help, it would be greatly appreciated. I will also say that this has all been a learning experience, so in some cases if you have to ask “Why did you do this?” the answer may be “because I’m dumb”. Hopefully the problem here is glaring to someone.

  • 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-24T11:00:17+00:00Added an answer on May 24, 2026 at 11:00 am

    Alright, there are a couple of things that I am seeing here that are incorrect. First of all, you should probably make currentRow a retained property, that way you do not have to retain it and release it yourself. Also, make sure your -dealloc method of your Row class look as follows:

    - (void)dealloc {
        self.FirstName = nil;
        self.LastName = nil;
        [super dealloc];
    }
    

    Make your currentRow a property like so:

    @property (nonatomic, retain) Row * currentRow;
    

    Then, assign it like self.currentRow = aRow. Also note that you will need to set self.currentRow = nil in the dealloc method as well. Your app is most likely crashing because you are not retaining currentRow on the line currentRow = [dataB getRow];.

    I would also like to point out that it is bad convention to capitalize the first letter of an instance variable.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I've got a string that has curly quotes in it. I'd like to replace
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am currently running into a problem where an element is coming back from
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

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.