Four reasons:
- I don't think anyone's written a bot in Objective-C yet.
- It tastes better than Java.
- Because I can.
- I feel like learning Objective-C and the Cocoa framework, and in my experience, a Battle.net bot is a hell of a crash-course.
That said, I'm not very far yet. Cocoa doesn't provide TCP sockets in it's framework, but since Objective-C is a superset of C, of course there's libraries. I'm personally using SmallSockets.
I'm also taking a new approach with this, which so far seems consistent with most Objective-C code, and that is that all functionality of objects is contained in the object. For example, instead of calling each get method on a ChatEvent, the ChatEvent itself is responsible for displaying it's contents to an NSTextView. This is a snippet for testing all Event ID's, as displayed in the screenshot.
- (IBAction)sendButtonClicked:(id)sender {
// Create new chat event
ChatEvent* event = [[ChatEvent alloc] init];
[event setUsername: @"TestUser"];
[event setText: [txtSend stringValue]];
for(int i = 0x01; i <= 0x17; i++) {
[event setEventID: i];
[event writeEventToNsTextView:chat];
}
[event release];
// Clear out the textbox
[txtSend setStringValue:@""];
}
My programming teacher recently gave the class an idea for a development technique, and that's to do it once and throw it away, then redo it when you know what you're doing. I think I'll do that with CocoaBot, since it's my first Objective-C project and I'm bound to do stuff totally wrong, and fixing them will take longer than rewriting the entire bot.
And lastly, if you haven't figured it out from the screenshot, it's for Mac. Objective-C can be compiled on Linux, but I don't know how much of Cocoa is open-source and how much is Apple code.