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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T02:36:11+00:00 2026-06-19T02:36:11+00:00

I have a simple utility app, with a MainViewController.m & h and a FlipsideViewController.m

  • 0

I have a simple utility app, with a MainViewController.m & h and a FlipsideViewController.m & h. Within my storyboard I have a button on MainViewController. I want to be able to click the button and run a method in FlipsideViewController.m is this possible? this is my first app and I am a total novice. all comments / suggestion welcome.

enter code here

i have this in my FlipsideViewController.m this is what i want to call when i click the button.

- (void)SaveFPQData
{
NSLog(@"Data Saved");
}

and this is what i have in MainViewController.m

- (IBAction)saveButton:(id)sender
{

}

This is the code I have so far;

MainViewController.h

#import "FlipsideViewController.h"
#import "sqlite3.h"
#import "FPQCheck.h"

@interface MainViewController : UIViewController <FlipsideViewControllerDelegate>

@property (weak, nonatomic) IBOutlet UITextField *nameField;
@property (weak, nonatomic) IBOutlet UITextField *checkField;
@property (weak, nonatomic) IBOutlet UITextField *commentsField;
@property (weak, nonatomic) FlipsideViewController *flipsidecontroller;

- (IBAction)saveButton:(id)sender;
- (IBAction)showHistoryButton:(id)sender;


@end

MainViewController.m

#import "MainViewController.h"
#import "FlipsideViewController.h"
#import "sqlite3.h"


@interface MainViewController ()

@end


@implementation MainViewController

- (void)viewDidLoad
{


[super viewDidLoad];
}

// Do any additional setup after loading the view, typically from a nib.


- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

#pragma mark - Flipside View

- (void)flipsideViewControllerDidFinish:(FlipsideViewController *)controller
{
[self dismissViewControllerAnimated:YES completion:nil];
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"showAlternate"]) {
    [[segue destinationViewController] setDelegate:self];
}
}


- (IBAction)saveButton:(id)sender
{
[self.flipsidecontroller SaveFPQData];


//[[NSNotificationCenter defaultCenter] postNotificationName:@"SaveFPQData" object:nil];
}

- (IBAction)showHistoryButton:(id)sender

{

}
@end

FlipSideViewController.h

#import <UIKit/UIKit.h>
#import "FPQCheck.h"

@class FlipsideViewController;

@protocol FlipsideViewControllerDelegate

- (void)flipsideViewControllerDidFinish:(FlipsideViewController *)controller;


@end

@interface FlipsideViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>


@property (weak, nonatomic) IBOutlet UITableView *myTableView;

@property (weak, nonatomic) id <FlipsideViewControllerDelegate> delegate;

-(void)SaveFPQData;


- (IBAction)done:(id)sender;
- (IBAction)deleteEntry:(id)sender;



@end

FlipSideViewController.m

#import "FlipsideViewController.h"
#import "MainViewController.h"


@interface FlipsideViewController ()
{
NSMutableArray *arrayOfCheck;
sqlite3 *fpqDB;
NSString *dbPathString;

}

@end

@implementation FlipsideViewController

- (void)viewDidLoad
{

/*
[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(SaveFPQData)
                                             name:@"SaveFPQData"
                                           object:nil];
 */


[super viewDidLoad];
arrayOfCheck = [[NSMutableArray alloc]init];
[self creatOrOpenDB];
[[self myTableView]setDelegate:self];
[[self myTableView]setDataSource:self];

// Do any additional setup after loading the view, typically from a nib.

}

- (void)SaveFPQData
{
NSLog(@"Data Saved");

}


-(void)creatOrOpenDB
{
NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask, YES);
NSString *docPath = [path objectAtIndex:0];
dbPathString = [docPath stringByAppendingPathComponent:@"FPQ.db"];

char *error;

NSFileManager *fileManager = [NSFileManager defaultManager];
if (![fileManager fileExistsAtPath:dbPathString]) {
    const char *dbPath = [dbPathString UTF8String];

    //create db

    if (sqlite3_open(dbPath, &fpqDB)==SQLITE_OK) {
        const char *sql_stmt = "CREATE TABLE IF NOT EXISTS FPQ (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT, CHECK INTEGER, COMMENTS TEXT)";
        sqlite3_exec(fpqDB, sql_stmt, NULL, NULL, &error);
        sqlite3_close(fpqDB);            
    }
}
}


- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

#pragma mark - Actions

- (IBAction)done:(id)sender
{
[self.delegate flipsideViewControllerDidFinish:self];}

- (IBAction)deleteEntry:(id)sender {

}


-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
} 

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [arrayOfCheck count];
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (!cell){
    cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}

FPQCheck *fpqCheck = [arrayOfCheck objectAtIndex:indexPath.row];

NSString *nameANDcheck = [NSString stringWithFormat:@"%@%d", fpqCheck.name, fpqCheck.check];

cell.textLabel.text = nameANDcheck;
cell.detailTextLabel.text = fpqCheck.comments;

return cell;

}

@end
  • 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-19T02:36:13+00:00Added an answer on June 19, 2026 at 2:36 am

    You have mainly two ways:

    1. add a property (eg. self.flipSideController) to your MainViewController to store a reference to the FlipsideViewController; then call SaveFPQData though it (eg. [self.flipSideController SaveFPQData]; or

    2. use notification center to post a notification from saveButton: that triggers SaveFPQData; this would go like this:

      //-- in flipsidecontroller `viewDidLoad`:
      [[NSNotificationCenter defaultCenter] addObserver:self
                                           selector:@selector(SaveFPQData)
                                               name:@"SaveFPQData"
                                             object:nil];
      
      //-- in saveButton:
      [[NSNotificationCenter defaultCenter] postNotificationName:@"SaveFPQData" object:nil];
      

    The second method is the simplest to implement, IMO, and it allows for the loosest coupling, at the expense of some clock cycles.

    EDIT:

    It is not entirely clear to me what you are trying to do (specifically, I don’t understand fully how you can push the button in MainViewController once you FlipsideViewController is displayed; on the other hand, if you do not segue to the FlipsideViewController, then it is not there, so you cannot send a message to it), anyway you could try and initialise your self.flipsideViewController property in prepareForSegue:

    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
    {
      if ([[segue identifier] isEqualToString:@"showAlternate"]) {
        UIViewController* controller = [segue destinationViewController];
        [controller setDelegate:self];
        if ([controller isKindOfClass:[FlipsideViewController class]])
             self.flipsideViewController = (id)controller;
      }
    }
    

    after doing that, your MainViewController will be able to send the saveFPQ message to the FlipsideViewController.

    If you mean you would like to send the saveFPQ message before segue-ing to the FlipsideViewController, you should make the saveButton segue to it and the call the saveFPQ method.

    What I suspect is you need some kind of “model” object accessible both from the main view and the flipside view controller.

    Hope this helps.

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

Sidebar

Related Questions

I have a very simple Office utility question. Open Microsoft word (2003 or 2007),
This should be simple. I'm making a very basic app, based on the Utility
I have a simple single threaded utility written in C# that inserts data into
I have a simple Android OpenGL-ES app, and as all the models are very
I have a small utility script written as .Net/C# console app purely for the
I am creating a simple utility app based on the xcode Utility App template.
I am writing my first Cocoa application. It's a simple utility app -- a
I have written a simple utility that loops through all C# files in my
I have a bunch of runnables I want to run in multiple threads and
I have developed a simple utility for my iPhone and iPad apps which places

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.