Reputation: 1
In my main view class, i have an instance of another class that is a connection via tcp socket.
When i leave that view , and than back, i don't want to free/lose this instance because i DONT want to make a new connection , it must stay the same (socket is like a chat-always connected)
socketInstance=[[SocketConnector alloc]init];
socketInstance.delegate=self;
This is done at the init
of the view , only at first launch. than, when i am leaving the view and come back (if i don't perform this lines again), will he save the socketInstance
reference for me ?
if not, how would i make him save it for the rest of the program lifetime ?
I cant create this instance again and again .
Upvotes: 1
Views: 62
Reputation: 11597
could you use a static variable? otherwise use a singleton pattern that you can keep global
Upvotes: 1