ObjectiveDDP
ObjectiveDDP copied to clipboard
MeteorClient can only be assigned an ObjectiveDDP delegate within AppDelegate
I'm trying to connect to a Meteor server but the connection only works when I set it up on the AppDelegate, but if I do it on my own NSObject-subclassed class, it crashes on
if ([self.delegate respondsToSelector:@selector(webSocketDidOpen:)]) {
[self.delegate webSocketDidOpen:self];
}
That's a SRWebSocket function, anyway, I suppose that it crashes because self.delegate, in this case my ObjectiveDDP class, is null, or because the ObjectiveDDP delegate is null, MeteorClient. I declare both classes properly, indeed, I declare them exactly the same when I do it on the AppDelegate and on my class.
Do you know why is this happening? I'm using the same code on both classes.
Yes, you're meteorclient needs to persist for the duration your app is alive, so it needs to be set in the appdelegate. The delegate ends up getting released.
On July 24, 2014 2:41:34 AM GMT+12:00, "Álvaro Franco" [email protected] wrote:
I'm trying to connect to a Meteor server but the connection only works when I set it up on the AppDelegate, but if I do it on my own NSObject-subclassed class, it crashes on
if ([self.delegate respondsToSelector:@selector(webSocketDidOpen:)]) { [self.delegate webSocketDidOpen:self]; }
That's a SRWebSocket function, anyway, I suppose that it crashes because self.delegate, in this case my ObjectiveDDP class, is null, or because the ObjectiveDDP delegate is null, MeteorClient. I declare both classes properly, indeed, I declare them exactly the same when I do it on the AppDelegate and on my class.
Do you know why this is happening? I'm using the same code on both classes.
Reply to this email directly or view it on GitHub: https://github.com/boundsj/ObjectiveDDP/issues/91
Sent from my Android phone with K-9 Mail. Please excuse my brevity.
What if I init my class as a singleton? It will always keep alive. Is there a workaround to perform this?
Are you initialising your class as a singleton? It should be fine if you do.
On 24/07/2014, at 8:23 am, Álvaro Franco [email protected] wrote:
What if I init my class as a singleton? It will always keep alive. Is there a workaround to perform this?
— Reply to this email directly or view it on GitHub.
Yeah, I'm initialising it as a singleton, but keep crashing anyway. Do you have any idea about why this is happening?
No I can't think of why, is there any reason you don't want it in the appdelegate? Can you provide the project code?
I can't since I'm working under NDA but there should be any reason. I want to have it implemented in other class in order to have a modular framework for our service, but in the case it's impossible, AppDelegate could do the trick
@AlvaroFranco I'd stick to AppDelegate for now, I will have to explore this issue when I get time. It could be a SocketRocket issue.