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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:52:09+00:00 2026-06-11T17:52:09+00:00

I am developing a Cocoa based application that will make several calls to a

  • 0

I am developing a Cocoa based application that will make several calls to a Postgres database (using PGSQLKit) over the course of a user’s transaction. The application is a kiosk of sorts.

What I’d like to know is the proper way to make database calls throughout the application. In the spirit of MVC, I know I should create objects for the data that is returned from the database (which I plan on doing) and then work with those objects. Where I need clarification is where I should place my database calls.

Basically it comes down to these questions I have:
-In order to interact with the database, should I create a separate database controller class that would make database calls? I feel making database calls directly from a view controller would not be appropriate.
-Assuming I create a database controller, should my view controllers trigger the database controller class and make DB calls that way?
-When the application loads, should I make a connection to the datase through the database controller and close it when the user’s transaction is complete? I’ll be making several calls throughout the transaction so I don’t think i should close the connection each time.

  • 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-11T17:52:10+00:00Added an answer on June 11, 2026 at 5:52 pm

    -In order to interact with the database, should I create a separate database controller class that would make database calls? I feel making database calls directly from a view controller would not be appropriate.

    Correct. In some cases you may even have another layer of model objects on top of the database controller. Most of the app shouldn’t care that the data is stored in a Postgres database rather than some other way.

    -Assuming I create a database controller, should my view controllers trigger the database controller class and make DB calls that way?

    Generally yes. Your view controllers will observe the model and tell the model when they need data. The model will let observers (including view controllers, though the model doesn’t care who they are) know when relevant data becomes available or changes.

    -When the application loads, should I make a connection to the datase through the database controller and close it when the user’s transaction is complete? I’ll be making several calls throughout the transaction so I don’t think i should close the connection each time.

    That is an internal detail to the database controller. Generally this kind of object would maintain a long-lived connection. Usually that connection is made the first time the model is asked for data that it needs from the database rather than “at application start.”

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

Sidebar

Related Questions

I'm developing a Cocoa Objective-C application that will run on Mac OS X. I
I am developing a cocoa application that will be making heavy use of both
I'm developing a Cocoa/Obj-C application that involves a WebView (from the WebKit framework). I've
I am developing an application in cocoa,which needs to check whether that app is
I am not much familiar with developing application using cocoa on mac. Can some
I am developing a Cocoa Application using the latest version of Xcode 4, I
I have a 64-bit-only application that I am developing in Objective-C on Cocoa. It
I'm developing a Cocoa application, and I'm using constant NSString s as ways to
I'm developing a Cocoa/Objective C application that reads the active document from any application
I'm developing a Cocoa application that shows a list of opened windows and highlights

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.