0
votes

I am downloading a sample project from this link.am using xcode 4.5 http://mobile.tutsplus.com/tutorials/iphone/building-a-jabber-client-for-ios-interface-setup/

not able to compile .The framework was missing.so i downloaded frame work from this link...https://github.com/robbiehanson/XMPPFramework ...filnaly i am able to compile.

then I add the my host name setupStream

-(void)setupStream { 
NSLog(@"setupStream"); 
xmppStream = [[[XMPPStream alloc] init]autorelease]; 
xmppStream.hostName=@"talk.google.com"; 
//xmppStream.hostPort=5222; 
[xmppStream addDelegate:self delegateQueue:dispatch_get_main_queue()];
}

But nothing will happen..The delegate method

-(void)xmppStreamDidConnect:(XMPPStream *)sender { 
NSLog(@"didReceiveMessage"); 
isOpen = YES; NSError *error = nil; 
[[self xmppStream] authenticateWithPassword:password error:&error];
}

-(void)xmppStreamDidAuthenticate:(XMPPStream *)sender { 
NSLog(@"didReceiveMessage"); 
[self goOnline];
}

is not being called.What am missing.Please help me..

2

2 Answers

2
votes

Most probably the problem is that your class instance, that is a delegate for your XMPPStream is released before the delegate method is called on it. Make it more persistent by making this class a property or instance variable of other class or by using dispatch_once. For example,

Change

YourClass *instance = [[YourClass alloc] init];
instance.xmppStream = .... 

by

@property(nonatomic, strong) YourClass *instance;
self.instance = [[YourClass alloc] init];
self.instance.xmppStream = .... 

Here YourClass contains XMPPStream and is delegate for it.

I've written a big blog post on this problem. This is pretty common situation. http://blog.alwawee.com/2013/07/31/on-xmppframework-delegate-method-not-being-called/

1
votes

Connecting

When you're ready, you can start the connection process:

NSError *error = nil;
if (![xmppStream connect:&error])
{
    NSLog(@"Oops, I probably forgot something: %@", error);
}

As you are not doing anything the delegate methods are not called. Depending on XMPPStream implementation you'll most likely get tons of memory issues, add somewhere a retained reference to the allocated object.