Objective C on iPhone: I am attempting to declare the following object at class level so that i do not have to re-connect this socket every time I write something to it. (Writing things multiple times a second) whenever i am writing a steady stream of live data, about every 2 seconds it freezes. I don't know why, but it does.
Code:
Socket *socket = [Socket socket];
[socket connectToHostName:@"10.0.2.3" port:1220];
I have tried declaring the variable in the instance data, then initializing it in +initialize and viewdidload, with no success or with errors. I have search for hours trying to find a way for this to work and after about 20 different solutions, I have found none that work. The socket, by the way, is an object from the smallsockets pack for objective-c.
Small sockets: http://smallsockets.sourceforge.net/
It works great, except for the live data freezing every few seconds. I have narrowed down parts of the code to those two lines. I know that creating and then connecting the socket is what is causing the delay.
Any help is much, much appreciated.
Thanks!!
[Edit]
Here is some sample code of my attempts: instance declaration:
Socket *socket;
viewDidLoad:
socket = [Socket socket]; //Throws error on compile
Alternate Viewdidload:
Socket *tempSocket = [Socket socket];
socket = tempSocket;
//This compiles fine, however it doesn't work when trying to use it