문제

If i were to make an instant messenger for iOS, how would i go about checking for new messages?

Would it involve continuous checks to a web service to see if there are any new messages (e.g. every few seconds), or some kind of live feed with the web service to update the app immediately?

도움이 되었습니까?

해결책

You can use NSStream and CSStream to communicate from within your iOS apps to a TCP server. Keeping an open socket connection with your server will allow the server to send you a notification about the new message instantly. You will need an output stream (NSOutputStream) and an input stream (NSInputStream) so you can manage outgoing and incoming communications easily and in parallel.

Some useful links:

Introduction to Stream Programming Guide for Cocoa

How To Create A Socket Based iPhone App and Server

Tutorial: Building A Simple iOS TCP Socket Based App Client And Server

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top