I’m making a game that uses nsstream to communicate with a server, and the program responds to the type of command coming for the stream (say the opponent jumps or shoots). If I have say 20 different types of commands, would:
1) 20 if statements (doubtful)
2) a switch
– or
3) an NSDictionary of selectors corresponding to keys of the command types
be the fastest way to respond to the stream data?
for 2) would I say pass in integers as the command type and convert the data into intValue and pass into the switch?
and for 3) would this be any faster than a switch, or would the lookup time and conversion make it not as fast?
I’ve been into gaming stream for quite much time. Among what you have suggested, I believe the
will be the fastest one to process.