2

so I have a class with the following interface:

#import <UIKit/UIKit.h>
#import "XMPPStream.h"

@interface SignInViewController : UIViewController
@property (strong, nonatomic) IBOutlet UITextField *UserNameTextField;
@property (strong, nonatomic) IBOutlet UITextField *PassWordTextField;
@property (strong, nonatomic) XMPPStream *myStream;
- (IBAction)SignInButtonPress:(UIButton *)sender;

@end

Then, if the SignInButtonPress Method is evaluated, I have this code:

- (IBAction)SignInButtonPress:(UIButton *)sender {
    self.myStream = [[XMPPStream alloc]init];
    [self.myStream addDelegate:self delegateQueue:dispatch_get_main_queue()];

    NSString *jid = self.UserNameTextField.text;
    jid = [jid stringByReplacingOccurrencesOfString:@"@" withString:@"(at)"];

    self.myStream.myJID = [XMPPJID jidWithString:self.UserNameTextField.text];
    //stream.jid = self.UserNameTextField.text;


    self.myStream.hostName = @"myAWSDNS.us-west-2.compute.amazonaws.com";
    NSError *error = [[NSError alloc]init];
    if ([self.myStream connectWithTimeout:0 error:&error] == YES)
    {
        NSLog(@"DId Connect!");
        //[self performSegueWithIdentifier:@"Move" sender:sender];
    }
    else
    {
        NSLog(@"ou");
    }


}

self.myStream connectWithTimeout seems to run fine, error is nil after the call, and I get "Did Connect" in the log.

However, even though I added self as a delegate of the xmppStream (see beginning of method), the delegate method

 -(void) xmppStreamDidConnect:(XMPPStream *)sender

does not get called, even though I have it implemented in the same class as:

-(void) xmppStreamDidConnect:(XMPPStream *)sender
{
    if ([sender authenticateWithPassword:self.PassWordTextField.text error:NULL] ==YES)
    {
        NSLog(@"authed!");
        [self performSegueWithIdentifier:@"move" sender:sender];
    }
    else
    {

    }
}

Why is the method not being called, and how can I troubleshoot and/or fix this?

Dharmesh Kheni
  • 67,254
  • 32
  • 154
  • 160
ChrisC
  • 822
  • 2
  • 10
  • 25

1 Answers1

1

As I use the XMPP Framework with Swift, I am not sure whether this helps you. In order to get it running in my app, I had to make sure to implement the XMPPStreamDelegate Protocol as well as to inherit from NSObject (which is given as you are inheriting from UIViewController) like so:

Swift:

class SignInViewController: UIViewController, XMPPStreamDelegate

Objective-C

@interface SignInViewController : UIViewController <XMPPStreamDelegate>
Cordt
  • 83
  • 1
  • 5