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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:33:14+00:00 2026-05-27T12:33:14+00:00

I have the right navigation bar button action,I have set an action for it

  • 0

I have the right navigation bar button action,I have set an action for it like the following:

-(IBAction)save:(id)sender
{
    //Code for saving entered data

    UITextField *fieldOne = [self.fields objectAtIndex:0];
    UITextField *fieldTwo = [self.fields objectAtIndex:1];
    UITextField *fieldThree = [self.fields objectAtIndex:2]; 

    sqlite3_stmt *statement;
    const char *dbpath = [databasePath UTF8String];

    if (sqlite3_open(dbpath, &remindersDB) == SQLITE_OK && textField.text != nil)
    {

        NSString *insertSQL = [NSString stringWithFormat:@"INSERT INTO reminders(name, event, date) VALUES (\"%@\", \"%@\", \"%@\")", fieldOne.text, fieldTwo.text,fieldThree.text];

        const char *insert_stmt = [insertSQL UTF8String];

        sqlite3_prepare_v2(remindersDB, insert_stmt, -1, &statement, NULL);

        NSLog(@"%@",fieldOne.text);
        NSLog(@"%@",fieldTwo.text);
        NSLog(@"%@",fieldThree.text);

        if (sqlite3_step(statement) == SQLITE_DONE)
        {
            UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"\n Reminder Saved." message:nil delegate:nil cancelButtonTitle:nil otherButtonTitles:nil];
            [alert show];
            [alert dismissWithClickedButtonIndex:0 animated:YES];
            [alert release];
        } 

        else 
        {
            UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Alert" message:@"Reminder not saved" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
            [alert show];
            [alert release];
        }

        rowID = sqlite3_last_insert_rowid(remindersDB);
        NSLog(@"last inserted rowId = %d",rowID);

        sqlite3_finalize(statement);
        sqlite3_close(remindersDB);

    }

    //Alert for not entering any data

    if ([textField.text length] == 0)
    {
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Fill Data" message:@"Please fill name,event and date of reminder" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
        [alert show];
        [alert release];
    }

    ++self.numberOfSaves;
    NSLog(@"Number of saves = %d",numberOfSaves);

    [self.tableView reloadData];

}

Now I want to check how many times the button is clicked,I have an idea in mind that to create a function and used the condition 

    -(int)numberOfSaves
    {

    int saves = 0;

    if(self.navigationItem.rightBarButtonItem.enabled==YES)
    {

          saves++;

    }
       return saves;
    }

It’s not working……

Is there anyway to check such condition,If so how can I achieve it,I am newbie to objective-c,please help me out…

Thanks all in advance 🙂

  • 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-27T12:33:14+00:00Added an answer on May 27, 2026 at 12:33 pm

    You cannot return from a void method.

    You’d want to change -(void)numberOfSaves to -(int)numberOfSaves, if that were the right way to go about things, but I don’t think this is what you want.

    In your header file (.h) you’ll want to declare an instance variable for the class:

    @property (nonatomic, strong) NSInteger numberOfSaves;
    

    In your implementation file (.m) make sure to synthesize it:

    @synthesize numberOfSaves = _numberOfSaves;
    

    Replace your IBAction method:

    - (IBAction)save:(id)sender
    {
        ++self.numberOfSaves;
    }
    

    And just throw away the -(void)numberOfSaves method all together. This should accomplish what I think you’re trying to do. You can figure out how many saves you have committed now with self.numberOfSaves

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

Sidebar

Related Questions

What is the best way to have the right navigation bar button flip like
Hi I need to set the button on right side, in navigation bar, programatically
I have a button as the right button on my navigation bar: UIBarButtonItem *addButton
How to set action to the backButtonItem on the navigation bar? I have a
Actually i am placing a bar button on right side of navigation bar, it's
I have a navigation bar with three buttons on the right (arrows for navigation
I have a horizontal navigation bar. Each button is a span with a background
In an iPhone app I want to have a navigation button on the right
I have a tab bar + navigation based app and I'd like to launch
I want to add a right bar button item to the navigation bar, so

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.