views:

82

answers:

3

I have information I'm planning to sync between an iPhone application and a desktop application via a PHP script; is there a method of calling the script in the background to send data to the online database and then retrieve the data from the script?

+1  A: 

You could just make it a web app instead of a native app

Phill Pafford
I suppose that's a possibility, but I'm also trying to work on something submittable to the iTunes store; would that still be an option with the web app route, or would Cocoa be essential for that?
Kaji
Cocoa is a no but if you wanted your webapp on the Apple site I think it still goes through a submission process.
Phill Pafford
A: 

See the URL Loading System and NSURLConnection. The "Related Sample code" on the NSURLConnection link may be helpful

ctshryock
A: 

If you wrap up all of your functions in a nice little class, you can use a method within the SDK to call a method in a separate thread. the method is called detachNewThreadSelector:toTarget:withObject:

Note if you don't want to do any processing of the returned data, than you can ignore this, and just use the standard approach to URL loading, as it is Asynchronous, and makes the connection in the background anyway, however the difference is that it's callback is called on the main thread (AFAIK). By executing in a separate thread, everything will be done there, so the UI will be free.

Also take care, the world of multi-threading can be long and rocky. Good luck

Jonathan