views:

2779

answers:

5

Is there a way in Cocoa that is currently considered best practice for creating a multi-tier or client server application?

I'm an experienced web developer and I really love Python. I'm new to Cocoa though. The application I'm toying with writing is a patient management system for a large hospital. The system is expected to store huge amounts of data over time but the data transferred during a single session is very light (mostly just text). The communication is assumed to occur over a local network (wired or wireless). It has to be highly secure, of course.

The best I could come up with is to write a Python REST web service and connect to it through the Cocoa app. Maybe I'll even use Python to code the Cocoa app itself.

Looking at Cocoa, I see really great technologies in Cocoa like CoreData but I couldn't find anything similar for client server development. I just want to make sure that I'm not missing anything.

What do you think?

Real world examples will be greatly appreciated.

Thanks in advance.

+1  A: 

Generally, the ideas of all other client/server frameworks are applicable.

Take a look at this link: http://developer.apple.com/internet/webservices/webservicescoreandcfnetwork.html

Mehrdad Afshari
A: 

Look at the api's for NSConnection and NSDownload to handle the network connection. The NSString class also has methods like + stringWithContentsOfURL:encoding:error: that may be useful.

Then there is NSXMLParser and NSXMLDocument for reading xml data.

Nathan Kinsinger
+2  A: 

Cocoa has Portable Distributed Objects, which let you build a client / server application in pure Objective-C and Cocoa which can communicate across processes or across a network.

Unfortunately it's one of the harder things to learn in Cocoa. Distributed objects haven't been updated to keep up with new technologies like bindings, there's not a lot of examples or documentation (and many of the tutorials are old, some even pre-dating OS X). There's also a lot of "gotchas," even for experienced Cocoa programmers, in the way objects are transmitted across the wire either as a copy or a proxy object. For example, you can transmit an NSURL from a server and it will seem fine if you convert it to a string or look at it in the debugger, but your client will crash if you try to use it in an NSURLConnection.

Depending on your experience it may be easier and quicker to use a web service, but it's still worth looking in to if you'd like to keep the entire project in Cocoa. Here's a tutorial if you'd like to see an example.

Marc Charbonneau
+4  A: 
Barry Wark
A: 

I have written a server and a client class for use in Cocoa. Using these classes makes it very easy to produce a server or client application without the knowledge about sockets and that C-stuff Just have a look at my website or at the sourceforge.net project site.