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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:11:00+00:00 2026-05-30T12:11:00+00:00

I am new to objective-c and I am trying to create an array of

  • 0

I am new to objective-c and I am trying to create an array of dictionaries in an effort to view them in a NSTableView with three columns. the sqlite DB schema has three columns as well, “foo”, “bar”, and “foobar” in a table called “tbl1”. i am using FMDB as a wrapper, and i can write and query successfully.

i can create an array for the entire DB with this:

FMResultSet *rs = [db executeQuery:@"select * from tbl1"];

and i can create a dictionary with this:

dict = [[NSMutableDictionary alloc] init];
[dict setObject: @"baz"        
      forKey: @"foo"];

reading each item in the DB works:

while ([rs next]) {
    NSLog(@"%@, %@, %@", 
          [rs stringForColumn:@"foo"],
          [rs stringForColumn:@"bar"],
          [rs stringForColumn:@"foobar"]);
    }

however, i cannot seem to create a single array of NSMutableDictionaries so I can read them into a cell-based table view. i was able to populate a single column with the identifier “foo” with the values for “foo”, however, that was just by making an array of “foo” items from an SQL query:

FMResultSet *rs = [db executeQuery:@"select * from tbl1"];
    while([foo next]) {
        NSString *thisFoo = [foos stringForColumn:@"foo"];        
        [_foos addObject:[NSString stringWithFormat:@"%@", thisFoo]];
    }
    NSLog(@"Foos: %@", _foos);

as a side note, i should be using mutable arrays and mutable dictionaries if i want to update the DB later? or will it not matter, as i would have to query the entire DB to refresh the table view anyway?
any suggestions on how to populate a three column tableview with a three column sqlite DB are appreciated – as well as corrections to my understanding of FMDB or tableviews.

  • 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-30T12:11:01+00:00Added an answer on May 30, 2026 at 12:11 pm
    FMResultSet *rs = (FMResultSet*)[db executeQuery:@"select * from tbl1"];
    NSMutableArray *totalArray = [[[NSMutableArray alloc]init]autorelease];
    while ([rs next]) {
    dict = [[NSMutableDictionary alloc] init];
    [dict setObject:[rs stringForColumn:@"foo"] forKey:@"COL1"];
    [dict setObject:[rs stringForColumn:@"bar"] forKey:@"COL2"];
    [dict setObject:[rs stringForColumn:@"foobar"] forKey:@"COL3"];
    [totalArray addObject:dict];
    [dict release];
    }
    return totalArray;
    

    should give you the array of dictionaries

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

Sidebar

Related Questions

I'm new to Objective-C and I'm trying to create a simple dictionary style app
I'm new to Objective-C, and I'm trying to create an app with two buttons
I'm new to Objective-C and trying to create custom cells. In the storyboard (under
I am new to Objective C and I am trying to implement an async
I am new in objective-c and I am trying to understand memory management to
I'm new to Objective-C and iPhone development, and I'm trying to store floating-point values
Background: I'm new to Objective-C and I've never touched C before. I'm trying to
I'm new to Objective-C, and I'm trying to find out the best way to
I'm new to Objective-c. For learning purposes I'm trying to build something like a
Completely new to Objective-C, trying to find out when I need to alloc and

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.