13

I'm currently making an iOS App for my school, and have no previous experience with iOS programming. However, I do have experience with HTML/PHP/MySQL.

Currently we have a basic tab bar application with 5 tabs at the bottom. Obviously, since this is an app for a school, it needs to be dynamic and hopefully we can set something up to connect to a database and retrieve school lunch menus, and news.

I know how to connect to a database normally with PHP, but I have no idea how to do it using the current version of Xcode. I've done research and apparently I need to use a webservice and json to safely get the information from the database.

Does anyone have any links for me to get started, because I have no experience at all with this program. I don't need to be spoonfed, but a point in the right direction would help. I really can't find any links for this new version of Xcode.

1

4 Answers 4

16

Here are two great tutorials that helped me a lot

How To Write A Simple PHP/MySQL Web Service for an iOS App

How to Write an iOS App That Uses a Web Service

Sign up to request clarification or add additional context in comments.

Comments

0

There are no "over the air" APIs that will let you connect directly to a MySQL database. Instead, what you could do is create a RESTful web service in front of the database that returns the data as JSON via a request from an NSURLRequest object.

Comments

0

By normally connection via PHP, what you actually mean is you had done web development. This means there was a server, and a database.

There's no available server in the iOS runtime that will allow you to install PHP or MySQL.

You can't do it...

But, you could make your php and database on a server, and connect to it via the network from your app.

My suggestion is to look what kind of database you need, if it's for school and it isn't really interactive with the outside world, then use SQLite in your app, it's an embedded database so it's on the phone, as quick as you can want, no networking and you can obviously leverage your SQL knowledge.

If you want to make an API or, server with your php things, you really are giving yourself a lot of extra work.

Comments

0

You need to create an NSMutableURLRequest and initialize an NSURLConnection with it to send an HTTP message. Something like that:

NSURL *url = [NSURL URLWithString:@"http://xyz.com"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"POST"];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.