0

I'm searching for a way to connect an app with a database, created in Sequel Pro which is connected with a mySQL Server (started over MAMP). I've already searched for some solutions but there are hundreds of different posts, some said that SQLite will be the only possibility, some others said that CoreData will be perfect.

Now I found a framework called 'MCPKit', but this framework isn't really up-to-date and it looks like Apple itself also recommends CoreData for Data Management. (https://developer.apple.com/technologies/ios/data-management.html)

I'm not familiar with CoreData and I'll be very happy if someone knows an other way to build up the connection.

I try to be as specific as possible but if you already have some questions, please ask.

RForce
  • 5
  • 1
  • 1
  • 2
  • Are you asking about using your database directly on the device, or connecting to the database over a network? – Jeff Wolski Apr 05 '13 at 13:31
  • Yeah sorry, I want to read the data from the database to implement it for example into a UITableView. I want to connect with the database over the network. – RForce Apr 05 '13 at 13:35

4 Answers4

3

Connecting to a mysql database IS possible. I did it via php which returned an xml file which my app parsed and stored.

This link also covers this topic as well.

How to connect to a MySQL database from an iPhone?

Community
  • 1
  • 1
Tim L
  • 170
  • 6
1

Core Data is a technology for persisting objects in iOS and is often used as a local database. In fact, the NSPersistentStore is almost always implemented as a SQLite database in iOS. However, if you are looking to make network calls to get data from the database on your server, Core Data does not do that.

The short answer is that you need to build a web service on your server that allows you to access the data. A good way (though certainly not the only way) to handle the communications between your service and mobile device is with sockets. Here is a tutorial that can get you a good start.

Jeff Wolski
  • 6,332
  • 6
  • 37
  • 69
0

CoreData actually uses SQLite... You can access your database with an NSURLRequest, then creating a NSData with the request. Depending on the format which your Server gives you back (i.e. JSON) you can transform the NSData into a Dictionary. This would look like this with JSON:

 NSDictionary *contentDictionary = [NSJSONSerialization JSONObjectWithData:contentServerResponse options:NSJSONReadingMutableContainers error:nil];

then you can access the Dictionary usual Key-Value-Access and assign the content to your ViewController.

Heckscheibe
  • 630
  • 7
  • 8
0

If you are using MAMP try writing php script files to access the mySQL db and echo it as JSON text using json_encode function in PHP. You have many parsers to parse JSON in iOS.

Mani
  • 561
  • 3
  • 8