XMPP is an open protocol for messaging and presence that most IM clients support.
If you're building a chat app for iOS that needs to interact with other clients, use XMPP. Read up and understand the protocol first, then look at the XMPPFramework Objective-C lib and it should all make sense. It'll take some time to learn though.
If your chat app needs to only communicate with other installations of your app, then you have a few easier options:
You could open a persistent tcp connection with the server and use that to pass presence and message data back and forth. You could implement a simple server to do this in node.js, for example, in a relatively small amount of code.
An even easier option is to call a simple http based api when you want to report new messages or presence changes from the iphone and deliver updates via push messages. Push messages are good because when the app is closed you can still deliver the message and when the app is open you can intelligently update your app's interface.
It's all about your requirements.