I've integrated following library from Cocoapods, You may find the code and its sample code at https://github.com/EugeneNguyen/XBChatModule
pod 'XBChatModule'
This library is used to integrate XMPP Chat in Xcode project. I also added suggested code from its ReadMe file. For your reference I am pasting it below
AppDelegate.m
[[XBChatModule sharedInstance] setUsername:@"admin"];
[[XBChatModule sharedInstance] setPassword:@"admin"];
[[XBChatModule sharedInstance] setHost:@"sflashcard.com"];
[[XBChatModule sharedInstance] connect];
[[XBChatModule sharedInstance] setAvatarFormat:@"http://dev.sflashcard.com/images/mantis_logo.png?test=%@"];
[[XBChatModule sharedInstance] setAvatarPlaceHolder:[UIImage imageNamed:@"girl_9"]];
The View controller is inherited from XBMessageViewController
ViewController.m
- (void)viewDidLoad
{
self.jidStr = @"binh.nx@sflashcard.com";
[super viewDidLoad];
}
- (void)viewWillAppear:(BOOL)animated
{
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadData) name:@"XBChatModuleNewAvatar" object:nil];
}
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)reloadData
{
[self.collectionView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:YES];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
The code works fine until I send a message. Whenever I press send button, it crashes the app by throwing following error in console
2015-09-01 17:20:41.742 Test[16064:251944] -[XBMessage messageHash]: unrecognized selector sent to instance 0x7ffc91cc4180
2015-09-01 17:20:41.800 Test[16064:251944] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[XBMessage messageHash]: unrecognized selector sent to instance 0x7ffc91cc4180'
*** First throw call stack:
(
0 CoreFoundation 0x000000011260aa75 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001122a3bb7 objc_exception_throw + 45
2 CoreFoundation 0x0000000112611d1d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x00000001125697ef ___forwarding___ + 495
4 CoreFoundation 0x0000000112569578 _CF_forwarding_prep_0 + 120
5 Test 0x000000010ebaf7ed -[JSQMessagesCollectionViewFlowLayout messageBubbleSizeForItemAtIndexPath:] + 301
6 Test 0x000000010ebb02a7 -[JSQMessagesCollectionViewFlowLayout sizeForItemAtIndexPath:] + 71
7 Test 0x000000010ebc5c93 -[JSQMessagesViewController collectionView:layout:sizeForItemAtIndexPath:] + 131
8 UIKit 0x00000001116369be -[UICollectionViewFlowLayout _getSizingInfos] + 988
9 UIKit 0x0000000111637839 -[UICollectionViewFlowLayout _fetchItemsInfoForRect:] + 526
10 UIKit 0x00000001116332b7 -[UICollectionViewFlowLayout collectionViewContentSize] + 66
11 Test 0x000000010ebc2d85 -[JSQMessagesViewController scrollToBottomAnimated:] + 325
12 Test 0x000000010ebc2c34 -[JSQMessagesViewController finishReceivingMessageAnimated:] + 388
13 Test 0x000000010ebc2aa0 -[JSQMessagesViewController finishReceivingMessage] + 48
14 Test 0x000000010ebfaac3 -[XBMessageViewController loadDataToTable] + 1507
15 Test 0x000000010ebf9be9 -[XBMessageViewController viewDidLoad] + 73
16 Test 0x000000010ead0760 -[ViewController viewDidLoad] + 96
17 UIKit 0x0000000111104580 -[UIViewController loadViewIfRequired] + 738
18 UIKit 0x000000011110477e -[UIViewController view] + 27
19 UIKit 0x0000000111023509 -[UIWindow addRootViewControllerViewIfPossible] + 58
20 UIKit 0x00000001110238a1 -[UIWindow _setHidden:forced:] + 247
21 UIKit 0x000000011102ff8c -[UIWindow makeKeyAndVisible] + 42
22 UIKit 0x0000000110fda0c2 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 2732
23 UIKit 0x0000000110fdce3e -[UIApplication _runWithMainScene:transitionContext:completion:] + 1349
24 UIKit 0x0000000110fdbd35 -[UIApplication workspaceDidEndTransaction:] + 179
25 FrontBoardServices 0x0000000115aab243 __31-[FBSSerialQueue performAsync:]_block_invoke + 16
26 CoreFoundation 0x000000011253fc7c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
27 CoreFoundation 0x00000001125359c5 __CFRunLoopDoBlocks + 341
28 CoreFoundation 0x0000000112535183 __CFRunLoopRun + 851
29 CoreFoundation 0x0000000112534bc6 CFRunLoopRunSpecific + 470
30 UIKit 0x0000000110fdb7a2 -[UIApplication _run] + 413
31 UIKit 0x0000000110fde580 UIApplicationMain + 1282
32 Test 0x000000010ead06d3 main + 115
33 libdyld.dylib 0x0000000112b3c145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
I understand it says, that I haven't implemented the function messageHash
in Class XBMessage
, but the same code works fine in the sample code that I download from Github. Kindly help me to solve this error.