Swift and SQL

Discussion in 'iOS Programming' started by Sony123, Jun 25, 2014.

  1. Sony123 macrumors newbie

    Apr 14, 2012
    Hi, I am student and need some help about swift with sql.

    I have some experience with java + mysql. I am just learning swift and programming for iOS devices.

    Now I need programing some application on iPad/iPhone and I need connecting to data from different iOS devices.

    Im thinking about how realize this.

    Have you any idea?

    Sorry for my English :)

  2. Kryckter macrumors 6502


    Mar 12, 2009
    Glad to help, but I dont understand completely. Do you want an app that connects to other phones and gets data?
  3. Sony123 thread starter macrumors newbie

    Apr 14, 2012
    I need to make an multi agent application. It must by possible log on by doctor or nurse. Doctor can set medicine by this application for many patients. Patients can check feed pills from their iOS device with this application.

    This is only for my bachelor thesis.

    Is it possible use SQL with swift? Or u must use only core data. But this data is saved only on one device and I cant access or update feed pills remotely.

  4. D.T. macrumors G3


    Sep 15, 2011
    Vilano Beach, FL
    What you’re going to want to do is build a web/cloud based API, that handles authentication, centralizes the data, applies various access control logic, etc.

    You likely wouldn’t be dealing the DB directly (i.e., Swift/Obj-C to DB), but via an application layer - it’s this layer that will handle the data access, and you _probably_ want to return the data in JSON - it’s structured, easily consumed on the iOS side, and very lightweight.

    Build it using a RESTful approach and it’s easily consumed from iOS, Android and the web.

    Also, when you say “SQL”, I’m assuming you mean a relational database, because I’m not sure you’d want to use MS/SQL for storage, vs. Postgres or mySQL ... but, I don’t know what resources you have available.
  5. ArtOfWarfare macrumors G3


    Nov 26, 2007
    Didn't Apple say something about iCloud storage at WWDC that could be used to share databases between devices running the same iOS application? That seems like it would be the easiest path to take to me. It'll require iOS 8, which is currently in beta, but assuming your project isn't due until later in the Fall that should be fine.
  6. D.T. macrumors G3


    Sep 15, 2011
    Vilano Beach, FL
    Yeah, there's iCloud + CloudKit, sounds pretty promising for people who don’t want to write their own backend:

  7. PhoneyDeveloper macrumors 68040


    Sep 2, 2008
    The question is a little vague so I'll try to answer broadly.

    sqlite is built-in on the device. See sqlite.org
    sqlite has a C API but there is an Objective-C interface to sqlite called FMDB. See https://github.com/ccgus/fmdb

    If you need remote data access then you need a web service. There is nothing really like jdbc. REST is the way to talk to your remote db. Before building my own web service I would look at existing services. Look at


    and there are others.
  8. AdonisSMU macrumors 603

    Oct 23, 2010
    Couldn't you just build your own api in NodeJS/Express and MogoDB for a backend and DB?
  9. PhoneyDeveloper macrumors 68040


    Sep 2, 2008
    You can build a web service in many different ways. If you are coming on this forum to ask how to talk to a db then answering 'build your own web service' probably isn't what you wanted to hear.

    If you already know how to build a web service then that might be a good solution for you. For the rest of us, using one of the existing services that I mentioned is probably better. But really it's up to OP to decide what works best for them.

Share This Page