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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:36:37+00:00 2026-05-30T13:36:37+00:00

In the below sample code, I am a bit lost as to why I

  • 0

In the below sample code, I am a bit lost as to why I am getting a NZombie on the line:

[Category getInitialDataToDisplay:[self getDBPath]];

I have looked through SO posts and other documentation but am new to objective-c and am spinning my wheels on this.

- (void)applicationDidFinishLaunching:(UIApplication *)application {

//Copy database to the user's phone if needed.
[self copyDatabaseIfNeeded];

// Init the Array
activeCategories = [[NSMutableArray alloc] init];
activeSubjects = [[NSMutableArray alloc] init];
categories = [[NSMutableArray alloc] init];
subjects = [[NSMutableArray alloc] init];
quotes = [[NSMutableArray alloc] init];
quoteMaps = [[NSMutableArray alloc] init];

//Initialize the Category array.
NSMutableArray *tempArray = [[NSMutableArray alloc] init];
self.categories = tempArray;
[tempArray release];

//Once the db is copied, get the initial data to display on the screen.
[Category getInitialDataToDisplay:[self getDBPath]];


//populate active subjects and categories: 

activeCategories = [self getActiveCategories];
activeSubjects = [self getActiveSubjects];

// sort data

NSSortDescriptor *categorySorter;
NSSortDescriptor *subjectSorter;

categorySorter = [[NSSortDescriptor alloc]initWithKey:@"category_title" ascending:YES];
subjectSorter = [[NSSortDescriptor alloc]initWithKey:@"title" ascending:YES];

NSArray *sortDescriptorsCat = [NSArray arrayWithObject:categorySorter];
NSArray *sortDescriptorsSub = [NSArray arrayWithObject:subjectSorter];

[self.categories sortUsingDescriptors:sortDescriptorsCat];
[self.subjects sortUsingDescriptors:sortDescriptorsSub];

[categorySorter release];
[subjectSorter release];

// Configure and show the window
[window addSubview:[navigationController view]];
[window makeKeyAndVisible];
}

…

- (void)dealloc {

[activeSubjects release];
[activeCategories release];

[categories autorelease];
[subjects autorelease];
[quotes autorelease];
[quoteMaps autorelease];
[navigationController release];
[window release];
[super dealloc];
}

Here is the getInitialDataToDisplay:

+ (void) getInitialDataToDisplay:(NSString *)dbPath {

// Use this section to bring in database and populate the array
FMDatabase *database = [FMDatabase databaseWithPath:dbPath];    
[database open];

QuotesAppDelegate *appDelegate = (QuotesAppDelegate *)[[UIApplication sharedApplication] delegate];


//appDelegate.categories = [appDelegate.categories sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];

//POPULATE THE SUBJECT 
FMResultSet *result_subjects = [database executeQuery:@"select * from SUBJECT"];

while([result_subjects next]) {

    NSInteger primaryKey = [result_subjects intForColumn:@"SUBJECT_ID"];
    Subject *sub = [[Subject alloc] initWithPrimaryKey:primaryKey];

    sub.title = [result_subjects stringForColumn:@"SUBJECT"];
    sub.category_title = [result_subjects stringForColumn:@"CATEGORY"];
    sub.active = [result_subjects intForColumn:@"ACTIVE"];
    sub.isDirty = NO;

    [appDelegate.subjects addObject:sub];
    [sub release];

}

FMResultSet *result_categories = [database executeQuery:@"select distinct category from SUBJECT"];

while([result_categories next]) {

    Category *cat = [[Category alloc] init];

    cat.category_title = [result_categories stringForColumn:@"CATEGORY"];
    NSLog(@"loading category: %@", cat.category_title);

    QuotesAppDelegate *appDelegate = (QuotesAppDelegate *)[[UIApplication sharedApplication] delegate];

    for (Subject *sb in appDelegate.subjects){

        if([cat.category_title isEqualToString:sb.category_title]){
            [cat.subjects addObject:sb];
            NSLog(@"   Adding subject: %@ cat.subjects.count=%i", sb.title, cat.subjects.count);

        }

    }

    [appDelegate.categories addObject:cat];
    [cat release];

}

//POPULATE THE QUOTES 
FMResultSet *result_quotes = [database executeQuery:@"select * from QUOTE"];

while([result_quotes next]) {

    Quote *sub = [Quote alloc];

    sub.quote_id = [result_quotes stringForColumn:@"QUOTE_ID"];
    sub.quote_date = [result_quotes stringForColumn:@"DATE"];
    sub.title = [result_quotes stringForColumn:@"DESC1"];
    sub.desc2 = [result_quotes stringForColumn:@"DESC2"];
    sub.excerpt = [result_quotes stringForColumn:@"EXCERPT"];
    sub.note = [result_quotes stringForColumn:@"NOTES"];
    sub.isDirty = NO;

    [appDelegate.quotes addObject:sub];
    [sub release];

}    


//POPULATE THE QUOTE_MAPS 
FMResultSet *result_quote_map = [database executeQuery:@"select * from QUOTE_MAP"];

while([result_quote_map next]) {

    QuoteMap *sub = [QuoteMap alloc];

    sub.quote_id = [result_quote_map stringForColumn:@"QUOTE_ID"];
    sub.quote_map_id = [result_quote_map stringForColumn:@"QUOTE_MAP_ID"];
    sub.subject_id = [result_quote_map stringForColumn:@"SUBJECT_ID"];
    sub.isDirty = NO;

    [appDelegate.quoteMaps addObject:sub];
    [sub release];

}    

[database close];

NSLog(@"Count of categories: %i", appDelegate.categories.count);
NSLog(@"Count of subjects: %i", appDelegate.subjects.count);
NSLog(@"Count of quotes: %i", appDelegate.quotes.count);
NSLog(@"Count of quoteMaps: %i", appDelegate.quoteMaps.count);

}

Here is the getDbPath:

- (NSString *) getDBPath {

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES);
NSString *documentsDir = [paths objectAtIndex:0];
return [documentsDir stringByAppendingPathComponent:@"reference.db"];
}
  • 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-30T13:36:38+00:00Added an answer on May 30, 2026 at 1:36 pm

    Sometimes, the best thing to do is build->analyze ( cmd shift b ). This will point out your bug right away in almost all cases.

    Best of luck!

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

Sidebar

Related Questions

I have a plot (sample code pasted below) that I am trying to add
I have created a sample here to show the issue.... http://bit.ly/j2nb1k The code is
I am still learning Sweave and R . I have below a sample code
I have a sample code snippet below which works just fine (I trimmed the
Below is sample code to create a radio button element with Yes/No options in
In the sample code below I am dividing by zero which when I step
In the below code sample, what does {0:X2} mean? This is from the reflection
I've put together a small code-sample below (Currently in C# 3.5 but would also
The code below shows a sample that I've used recently to explain the different
The code below generates a warning CS3006 Overloaded method MyNamespace.Sample.MyMethod(int[])' differing only in ref

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.