I want to implement a library for the America's Cup Data Stream API in Objective-C and was looking around if there already existed one and found an implementation in C# which I find beautiful and want to borrow some ideas from. This being the first C# source code I've seen so I do not fully understand what is happening.
The following is a sample program that using the C# library. It starts a Client that deal with network communication and a FeedEvents that takes care of the message dispatch. Then something interesting happens, it looks like a lambda expression is being used to specify the action when OnChatterText occurs, right? How do I do this in Objective-C? Using blocks?
class Program
{
static void Main(string[] args)
{
var c = new Client();
var e = new FeedEvents();
e.OnChatterText += ch => Console.WriteLine(string.Format("{0}: {1}",
ch.Source, ch.Text));
c.OnMessage += e.MessageHandler;
c.Connect();
Thread.Sleep(Timeout.Infinite);
}
}