开发者

Using Gdata and Xmpp protocol both in one application

I am integrating two apps into one. the first app is a chat app. We have used xmpp framework for retrieving Gmail chat buddies form Gmail account. In the other app we have used Google Data Protocol for logging into gmail account and retrieve all the contacts. When I integrate both these projects, I got a peculiar problem.

Both Google Data Protocol and XMPP define the nsxml objects.

Eg : in XMPP the nsxml elements are defined as follows

 #ifndef NSXMLElem开发者_JAVA技巧ent
   #define NSXMLElement DDXMLElement
 #endif

#ifndef NSXMLDocument
  #define NSXMLDocument DDXMLDocument
#endif

and in Google Data Protocol nsxml elements are defined as follows

#define NSXMLDocument  GDataXMLDocument
#define NSXMLElement   GDataXMLElement

My problem is both the protocols are defining nsxml objects. So it gives me an error when i try to send chat messages like :

-[GDataXMLElement addAttributeWithName:stringValue:]: unrecognized selector sent to instance 0x8101450
2010-12-14 19:12:32.430 GMIProject[1870:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GDataXMLElement addAttributeWithName:stringValue:]: unrecognized selector sent to instance 0x8101450'
*** Call stack at first throw:
(
 0   CoreFoundation                      0x029c1b99 __exceptionPreprocess + 185
 1   libobjc.A.dylib                     0x034b440e objc_exception_throw + 47
 2   CoreFoundation                      0x029c36ab -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
 3   CoreFoundation                      0x029332b6 ___forwarding___ + 966
 4   CoreFoundation                      0x02932e72 _CF_forwarding_prep_0 + 50
 5   GMIProject                          0x000057f2 -[ChatViewController send:] + 410
 6   UIKit                               0x0048a7f8 -[UIApplication sendAction:to:from:forEvent:] + 119
 7   UIKit                               0x0069668b -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 156
 8   UIKit                               0x0048a7f8 -[UIApplication sendAction:to:from:forEvent:] + 119
 9   UIKit                               0x00515de0 -[UIControl sendAction:to:forEvent:] + 67
 10  UIKit                               0x00518262 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
 11  UIKit                               0x00516e0f -[UIControl touchesEnded:withEvent:] + 458
 12  UIKit                               0x004ae3d0 -[UIWindow _sendTouchesForEvent:] + 567
 13  UIKit                               0x0048fcb4 -[UIApplication sendEvent:] + 447
 14  UIKit                               0x004949bf _UIApplicationHandleEvent + 7672
 15  GraphicsServices                    0x03871822 PurpleEventCallback + 1550
 16  CoreFoundation                      0x029a2ff4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
 17  CoreFoundation                      0x02903807 __CFRunLoopDoSource1 + 215
 18  CoreFoundation                      0x02900a93 __CFRunLoopRun + 979
 19  CoreFoundation                      0x02900350 CFRunLoopRunSpecific + 208
 20  CoreFoundation                      0x02900271 CFRunLoopRunInMode + 97
 21  GraphicsServices                    0x0387000c GSEventRunModal + 217
 22  GraphicsServices                    0x038700d1 GSEventRun + 115
 23  UIKit                               0x00498af2 UIApplicationMain + 1160
 24  GMIProject                          0x00002422 main + 84
 25  GMIProject                          0x000023c5 start + 53

Here my chat application calls the functions of xmpp framework, but since the NSXml objects has been redefined and overwritten by GData objects, the function of GData are being called which raises the exception.


I know this is old but I just came across a similar problem, and maybe this will help you out.

I changed the define for the another library (short name is K) that I am using so it now is marked with something like this.

#define NSXMLDocumentK DDXMLDocument 
#define NSXMLElementK DDXMLElement 
#define NSXMLNodeK DDXMLNode
#define NSXMLNodePrettyPrintK DDXMLNodePrettyPrint

and the google library is still defined as it is normally. Then everywhere I use the K code I changed it to the correct define. I ran my code and it appears to work for me.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜