iOS loading and writing string or variables through php

In iOS 5.1, local file storage is no longer available without using CoreData. For some small and temporary project, using php with simple write file function could be a way out.

1. Create a local network with a php server running on 1 of the server.

2. Create a php file in your server that could write a string (e.g. a comma separated string) to a text file stored on the webserver.

3. in your iOS app, use the following lines for read string from the server.

NSString *locationString = [NSString stringWithContentsOfURL:[NSURL URLWithString:@""] encoding:NSUTF8StringEncoding error:&error];

4. To write a file, simply use the POST method to send a simple string to a relative php page.

The good thing about this method is it is easy to implement, especially for web developer, however it is not a practical way for general app applications. Since we can’t always be sure that the app is being ran with a network/internet connection.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s