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

  • Home
  • SEARCH
  • 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 3986014
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:57:39+00:00 2026-05-20T05:57:39+00:00

Hello friends I am developing application in which view has one textField & 2

  • 0

Hello friends
I am developing application in which view has one textField & 2 buttons. When user clicks on “Add” then text from textfield should be stored in datatabse. When user clicks on “Display”then data fetched from database should be displayed in textField. The code written is like this

//SettingsApplicationViewController.h

#import "FMDatabase.h"

@interface SettingsApplicationViewController : UIViewController {

    FMDatabase *db;

    IBOutlet UITextField *urlField;

    IBOutlet UIButton *insertButton;

    IBOutlet UIButton *displayButton;

}

@property(nonatomic, retain) IBOutlet UITextField *urlField;

@property(nonatomic, retain) IBOutlet UIButton *insertButton;

@property(nonatomic, retain) IBOutlet UIButton *displayButton;

-(void)insertButtonClicked :(id)sender;

-(void)displayButtonClicked:(id)sender;

-(id)initApp;


@end

//  SettingsApplicationViewController.m

    #import "SettingsApplicationViewController.h"
#import "FMDatabase.h"

@implementation SettingsApplicationViewController


@synthesize urlField;

@synthesize insertButton;

@synthesize displayButton;

-(id)initApp

{

    if(![super init])
        return nil;

    //DB stored in application bundle
    NSString *DBName = @"SettingDB.sqlite";
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *path = [documentsDirectory stringByAppendingString:DBName];

    db = [FMDatabase databaseWithPath:path];
    [db setLogsErrors:TRUE];
    [db setTraceExecution:TRUE];

    if(![db open])
    {
        NSLog(@"Could not open Database");
        return 0;
    }

    else
    {
        NSLog(@"Database opened successfully");
    }
    return self;
}


    - (void)viewDidLoad {
    [super viewDidLoad];
    [self initApp];
}


    -(void)insertButtonClicked :(id)sender
{

[db executeUpdate:@"insert into Settings values (?)",urlField.text];
    [self resignFirstResponder];

}

    -(void)displayButtonClicked:(id)sender

{

    NSString *returnResult = [[NSString alloc]init];
    FMResultSet *rs = [db executeQuery:@"select url from Settings"];
    while ([rs next])
    {
        returnResult = [rs stringForColumn:@"url"];
        [urlField setText:returnResult];
    }


}

// SettingDB.sqlite

CREATE TABLE Settings(url text(50));

I created connections in IB & copied libsqlite3.dylib & FMDatabase file. I dont know why ” # ” is not printed in this post but I have # in my code.

When I compile this code it is showing 1 error as follows

Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1

Please help me friends.
Thanks

  • 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-20T05:57:39+00:00Added an answer on May 20, 2026 at 5:57 am

    Have you assigned Action for those buttons?

    If not do as follows,

    Instead of -(void)insertButtonClicked :(id)sender; use -(IBAction)insertButtonClicked :(id)sender; and assign them to respective button action.

    or else,

    In viewdidLoad,

    [insertButton addTarget:self action:@selector(insertButtonClicked:)   forControlEvents:UIControlEventTouchUpInside]; 
    [displayButton addTarget:self action:@selector(displaytButtonClicked:)   forControlEvents:UIControlEventTouchUpInside]; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hello friends i am developing one intranet application called human resource information system using
hello friends i have created a UDP chatting program through which the clients can
Hello friends i am running code given below which contains the setLogTimeEntery function and
Hello friends I am using this code in my view.. Using this code I
Hello friends i am to add optional parameter to pass these in a method
Hello Friends i have the following query which defeat the very purpose. A day
hello friends following is my query where displaylist is object if stringBuilder which have
Hello friends I am trying to add a class to body dynamically depending on
Hello I have the following error by git-fsck, which cannot be cleaned by git-gc
Hello we have an SQL server application running over a low bandwith connection. We

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.