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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:14:07+00:00 2026-05-28T08:14:07+00:00

I am developing one application. In that iam using the NSMutableArray for storing the

  • 0

I am developing one application. In that iam using the NSMutableArray for storing the database data. After getting the data from database into this array. I am performing the search operation on that data. In that time everytime that array returns last object only. But at the time of retrieving the data from database it retrives different data. So please tell me how to solve this one. Part of my code is shown below.

 -(void)searchData
{
    list=[db getlanguages];

     for(for i=0;i<[list count];i++) {
    databasefields *dbfield = [list objectAtIndex:i];
    NSLog(@"%@",dbfield.lang);
}


}

In this code list is the NSMutableArray.I will assign the memory for that one. And st the property for that one.

and code for [db getlanguages] is below.

 -(NSMutableArray*)getlanguages
{
NSString *query = [NSString stringWithFormat:@"SELECT * FROM A"];
sqlite3_stmt *stStatement;
NSMutableArray *getdata = [[NSMutableArray alloc]init];
if(sqlite3_prepare_v2(dbfile, [query UTF8String], -1, &stStatement, nil)==SQLITE_OK)
{
    databasefields *dbfields=[[databasefields alloc]init];
    while (sqlite3_step(stStatement)==SQLITE_ROW) 
    {
        dbfields.num=sqlite3_column_int(stStatement, 0);
        dbfields.lang=[NSString stringWithUTF8String:(char*)sqlite3_column_text(stStatement, 1)];
        [getdata addObject:dbfields];
        [dbfields release];
    }

    if (stStatement!= nil) {
        sqlite3_finalize(stStatement);
    }
}

sqlite3_close(dbfile);
return getdata;
}
  • 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-28T08:14:07+00:00Added an answer on May 28, 2026 at 8:14 am

    Modify the following line

     for(for i=0;i<[list count];i++) {
    

    to

     for(int i=0;i<[list count];i++) {
    

    and try.

    Edit

    You are using a single object and that you are releasing that too..

    Make your statements as follows:

    if(sqlite3_prepare_v2(dbfile, [query UTF8String], -1, &stStatement, nil)==SQLITE_OK)
    {
        databasefields *dbfields = nil;
        while (sqlite3_step(stStatement)==SQLITE_ROW) 
        {
            dbfields = [[databasefields alloc]init];
            dbfields.num=sqlite3_column_int(stStatement, 0);
            dbfields.lang=[NSString stringWithUTF8String:(char*)sqlite3_column_text(stStatement, 1)];
            [getdata addObject:dbfields];
            [dbfields release];
        }
    
        if (stStatement!= nil) {
            sqlite3_finalize(stStatement);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing one application.In that iam using the progress view.In this i need
Iam developing one application.In that i take the string from array and replace .xml
I'm developing one application for iphone using phone gap.I that I need to display
I am developing one application in android. In this I have to login into
Possible Duplicate: What's the Best Way to Shuffle an NSMutableArray? iam developing one application.In
I am developing one application that requires records from Addressbook , I need all
I am developing one console application using perl script. In that I am printing
Iam developing one applciation.In that application i used the both imageview and textview.And iam
This is a console application that I am developing using VS2010 in C#. II
I am developing one web application. In that i want to use variable's value

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.