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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:17:24+00:00 2026-05-24T12:17:24+00:00

I have NSMutable array that holds data captured from external sensor through iphone. I

  • 0

I have NSMutable array that holds data captured from external sensor through iphone. I want to dump that array into database in another file. And I have no idea how is it done.

Database class

- (id) init {
    self = [super init];

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,       NSUserDomainMask, YES);
    NSString *documentsDirecotry = [paths objectAtIndex:0];
    NSString *databaseFilePath = [documentsDirecotry  stringByAppendingPathComponent:@"ForceGaugeDatabase"];

    BOOL databaseExists = [[NSFileManager defaultManager] fileExistsAtPath:databaseFilePath];
    database = [[FMDatabase alloc] initWithPath:databaseFilePath];
    if(!databaseExists){
        [self createDatabase];
    }
    return  self;
}


-(void) createDatabase{

    [database open];

    NSString *query = [NSString stringWithString:@"CREATE TABLE forcegauge (forcelb INTEGER, forcekg INTEGER, forcenewton INTEGER, forceoz INTEGER, analoginput INTEGER);"];
    if([database executeUpdate:query]) {

        for(int i = 0; i < 6 ; i++) {
            query = [NSString stringWithFormat:@"insert into forcegauge (forcelb, forcekg, forcenewton, forceoz, analoginput) values (%d,20,30,40,100,9);", i];
            [database executeUpdate:query];

            query = [NSString stringWithFormat:@"insert into forcegauge (forcelb, forcekg, forcenewton, forceoz, analoginput) values (%d,34,45,55,90,2);", i];
            [database executeUpdate:query];

            query = [NSString stringWithFormat:@"insert into forcegauge (forcelb, forcekg, forcenewton, forceoz, analoginput) values (%d,35,55,65,95,3);", i]; 
            [database executeUpdate:query];

            query = [NSString stringWithFormat:@"insert into forcegauge (forcelb, forcekg, forcenewton, forceoz, analoginput) values (%d,40, 53, 67,90,4);", i];
            [database executeUpdate:query];
        }   
    } else {
        NSLog(@"Error Creating Table");
    }
    [database close];     
}

Class with NSMutableArray.

-(void) forceCalculationKg{
    NSNumber *number = [controller. analogInValues objectAtIndex:0];
    [controller enableDigitalInputs:YES]; 
    double value = [number doubleValue];
    double force; 
    force = 0.2908  *pow(2.718,(1.2089 * value));
    double forcekg;
    forcekg = force/2.2;
    [kgarray addObject:[NSNumber numberWithDouble:forcekg]];

    forceoutput.text = [NSString stringWithFormat:@" %0.1f", forcekg];
}

So here kgarray holds all the data that is being updated through an external sensor attached. And I want to transfer the data held by kgarray to ForceGaugeDatabase.

  • 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-24T12:17:25+00:00Added an answer on May 24, 2026 at 12:17 pm

    To insert rows from arrays into your table you need to iterate through arrays and execute queries.

    NSUInteger totalRows = [firstArray count]; // I suppose, that each array has the same number of items
    for (NSUInteger i = 0; i < totalRows; ++i) {
        NSNumber *forcelb = [firstArray objectAtIndex:i];
        NSNumber *forcekg = [secondArray objectAtIndex:i];
        .....
        NSString *query = [NSString stringWithFormat:@"insert into forcegauge (forcelb, forcekg, forcenewton, forceoz, analoginput) values (%f , %f, 53, 67,90,4);", [forcelb doubleValue], [forcekg doubleValue]];
        [database executeUpdate:query];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to store my CGPoint to the NSMutable Array, so , I have
So I have an NSMutable array that I populate in viewDidLoad and then I
Newbie question. I have a NSMutableArray that holds multiple objects (objects that stores Bezier
I have a Cocos2D iPhone application that requires a set of CGRects overlaid on
I have a class called Shop that contains data members ( NSString , NSInteger
I have a NSMutableArray that holds a collection of UIViewControllers Amongst other properties and
Whew... what a title. So I have a NSMutableArray that is assigned data retrieved
I have a UITableView I'm populating with data from CoreData. I have a data
I have an NSMutableArray that holds multiple and changing amounts (that's why I am
I have an NSMutableArray , purDesc , that holds an NSMutableDictionary , purDetails .

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.