ObjectiveDDP icon indicating copy to clipboard operation
ObjectiveDDP copied to clipboard

MeteorClient can only be assigned an ObjectiveDDP delegate within AppDelegate

Open AlvaroFranco opened this issue 10 years ago • 7 comments

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.

AlvaroFranco avatar Jul 23 '14 14:07 AlvaroFranco

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.

mikey0000 avatar Jul 23 '14 19:07 mikey0000

What if I init my class as a singleton? It will always keep alive. Is there a workaround to perform this?

AlvaroFranco avatar Jul 23 '14 20:07 AlvaroFranco

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.

mikey0000 avatar Jul 23 '14 21:07 mikey0000

Yeah, I'm initialising it as a singleton, but keep crashing anyway. Do you have any idea about why this is happening?

AlvaroFranco avatar Jul 24 '14 08:07 AlvaroFranco

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?

mikey0000 avatar Jul 27 '14 21:07 mikey0000

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 avatar Jul 27 '14 22:07 AlvaroFranco

@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.

mikey0000 avatar Jul 29 '14 01:07 mikey0000