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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:03:10+00:00 2026-06-16T00:03:10+00:00

I am having a requirement in which I have 5 keys stored in a

  • 0

I am having a requirement in which I have 5 keys stored in a NSDictionary corresponding to which I have stored 5 values from different arrays. My data structure looks like:

Dictionary is {

1 =     (
                {
            SubRegionName = "abc";
            WalkId = 123;
            WalkName = xyz;
        },
        {
        },....
2 =     (
                {
            SubRegionName = "abc";
            WalkId = 123;
            WalkName = xyz;
        },
        {
        },....
3 =     (
                {
            SubRegionName = "abc;
            WalkId = 123;
            WalkName = xyz;
        },
        {
        },....
4 =     (
                {
            SubRegionName = "abc";
            WalkId = 123;
            WalkName = xyz;
        },
        {
        },....
5 =     (
                {
            SubRegionName = "abc";
            WalkId = 123;
            WalkName = xyz;
        },
        {
        },
        )

The above data I am getting from sqlite according to some Id say tempId(1,2,3,4,5) and I want to use them separately. As I have to display the walkName as cell.textlabel.text and SubregionName as cell.detailtext.text in tableview.

I am not getting how to access this data from the dictionary. Can anyone please suggest me right way to do it.

My code is:

// For Database queries (To get data from database) ***********

-(void)getMainRegions
{
    sqlite3 *walkNameDB;
    if (sqlite3_open([[self databasePath] UTF8String], &walkNameDB) != SQLITE_OK) {
        sqlite3_close(walkNameDB);
        NSAssert(0, @"Failed to open Walk name database");
    }



    NSString *regionQuery = @"SELECT Rid,RName from MainRegions";

    sqlite3_stmt *teststatement = nil;

   // NSLog(@"%d",sqlite3_prepare_v2(walkNameDB,[regionQuery UTF8String], -1, &teststatement, nil));

    if (sqlite3_prepare_v2(walkNameDB,[regionQuery UTF8String], -1, &teststatement, nil) == SQLITE_OK)
    {
        RNameArray = [[NSMutableArray alloc] init];
        RIdArray = [[NSMutableArray alloc] init];

        while( sqlite3_step(teststatement) == SQLITE_ROW )
        {

            NSNumber *RId;
            int temp1 = (int)sqlite3_column_int(teststatement, 0);
            RId = [[NSNumber alloc] initWithInt:temp1];

            char *RNameCharacter;
            RNameCharacter = (char *) sqlite3_column_text(teststatement, 1);
            NSString *RNameString = [[NSString alloc] initWithUTF8String:RNameCharacter];

            [RNameArray addObject:RNameString];
            [RIdArray addObject:RId];


        }

    }
    [self getWalks];
}

-(void)getWalks
{
    sqlite3 *walkNameDB;
    if (sqlite3_open([[self databasePath] UTF8String], &walkNameDB) != SQLITE_OK) {
        sqlite3_close(walkNameDB);
        NSAssert(0, @"Failed to open Walk name database");
    }

    RegionWalksDictionary = [[NSMutableDictionary alloc] init];

    for(regionId in RIdArray)
    {
        regionWalkArray = [[NSMutableArray alloc] init];
        NSString *walkQuery = [[NSString alloc] initWithFormat:@"SELECT Wid,WName,SName from Walks,SubRegions WHERE Walks.Sid=SubRegions.Sid AND Rid = %d",[regionId integerValue] ];

        sqlite3_stmt *walkstatement = nil;

     //   NSLog(@"%d",sqlite3_prepare_v2(walkNameDB,[walkQuery UTF8String], -1, &walkstatement, nil));

        if (sqlite3_prepare_v2(walkNameDB,[walkQuery UTF8String], -1, &walkstatement, nil) == SQLITE_OK)
        {
            while( sqlite3_step(walkstatement) == SQLITE_ROW )
            {
                NSNumber *WId;
                int temp1 = (int)sqlite3_column_int(walkstatement, 0);
                WId = [[NSNumber alloc] initWithInt:temp1];

                char *WNameCharacter;
                WNameCharacter = (char *) sqlite3_column_text(walkstatement, 1);
                NSString *WNameString = [[NSString alloc] initWithUTF8String:WNameCharacter];

                char *SNameCharacter;
                SNameCharacter = (char *) sqlite3_column_text(walkstatement, 2);
                NSString *SNameString = [[NSString alloc] initWithUTF8String:SNameCharacter];

                NSMutableDictionary *tempWalk = [[NSMutableDictionary alloc] init];
                [tempWalk setObject:WId forKey:@"WalkId"];
                [tempWalk setObject:WNameString forKey:@"WalkName"];
                [tempWalk setObject:SNameString forKey:@"SubRegionName"];
                [regionWalkArray addObject:tempWalk];
            }
        }


        [RegionWalksDictionary setObject:regionWalkArray forKey:regionId];
     //   NSLog(@"arr%@",RegionWalksDictionary);

    }

}

//*** Methods to get data from database ends here **************

  • 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-06-16T00:03:11+00:00Added an answer on June 16, 2026 at 12:03 am

    Try this way…

    for(id dict in RegionWalksDictionary){
    
            NSLog(@"WalkId: %@",[[[RegionWalksDictionary objectForKey:dict]objectAtIndex:0]objectForKey:@"WalkId"] );
            NSLog(@"WalkName: %@",[[[RegionWalksDictionary objectForKey:dict]objectAtIndex:0]objectForKey:@"WalkName"] );
            NSLog(@"SubRegionName: %@",[[[RegionWalksDictionary objectForKey:dict]objectAtIndex:0]objectForKey:@"SubRegionName"] );
            NSLog(@"----");
    
    }
    

    I have used as following (comment if this is not the structure or your data)

    NSMutableDictionary *RegionWalksDictionary=[NSMutableDictionary new];
    NSMutableArray *regionWalkArray=[NSMutableArray new];
    NSMutableDictionary *tempWalk=[NSMutableDictionary new];
    
    [tempWalk setObject:@"wk1" forKey:@"WalkId"];
    [tempWalk setObject:@"wkName1" forKey:@"WalkName"];
    [tempWalk setObject:@"srName1" forKey:@"SubRegionName"];
    
    [regionWalkArray addObject:tempWalk];
    
    [RegionWalksDictionary setObject:regionWalkArray forKey:@"1"];
    [RegionWalksDictionary setObject:regionWalkArray forKey:@"2"];
    [RegionWalksDictionary setObject:regionWalkArray forKey:@"3"];
    
    NSLog(@"tempWalkd dict is %@",RegionWalksDictionary);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having some requirement in which I have to find out if the
I'm having the requirement, to insert a specific amount of rectangles (which have a
Hi i all having a requirement to delete particular data from a text file.
I have a requirement for php script which works as below.The Database is having
Hii I have a requirement of calling the variable in function which is having
I have a simple spring batch program which reads data from a INPUT file
i have a requirement in which i will retrieve all the records from the
I have a weird requirement which I need to use inside my Stored Procedure
I have a requirement to build a slightly unusual data model, but I'm having
I am kinda having a strange requirement. I have a google talk bot &

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.