I got error in NSPredicate
"*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to parse the format string "title tcontains[cd] %#"'
*** First throw call stack:
(0x15d6012 0x13fbe7e 0xe14355 0xe14173 0xe14127 0x5b68 0x5deb 0x626ff3 0x576c86 0x140f705 0x343213 0x404c7e 0x404310 0x41113c 0x41b5a6 0xebc4f9 0x16300c5 0x158aefa 0xdf0bb2 0x406e9de 0x31bc1da 0x35f5dfc 0x35f8bf8 0x4049612 0x404974a 0x4049ec0 0x4049cb8 0x4049204 0x343722b 0x3437193 0x401be96 0x40484cc 0x35f3136 0x35f23c6 0x3625980 0x3c817fd 0x361c576 0x361d6da 0x361b72e 0x3c7feaa 0x3635af1 0x362572a 0x35f96ae 0x31f862b 0x140f6b0 0x4064810 0x32371a4 0x32392ff 0x5010b4 0x4c3aef 0x4c4e58 0x4c39fe 0x4cdd29 0x350ddb 0x44e7f5 0x44e7f5 0x44e7f5 0x44e7f5 0x44e7f5 0x44e7f5 0x44e7f5 0x44e7f5 0x44e7f5 0x44e7f5 0x350e35 0x350806 0x350beb 0x342698 0x22fcdf9 0x22fcad0 0x154bbf5 0x154b962 0x157cbb6 0x157bf44 0x157be1b 0x22fb7e3 0x22fb668 0x33fffc 0x201d 0x1f45)
libc++abi.dylib: terminate called throwing an exception"
Please help me.
Here is the my code
- (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope
{
[searchResults removeAllObjects];
NSString *str1 = [searchText stringByReplacingOccurrencesOfString:#"\"" withString:#""];
NSLog(#"data_arra==>%#",arr_search);
NSLog(#"searchText==>%#",searchText);
NSPredicate *resultPredicate = [NSPredicate
predicateWithFormat:#"title tcontains[cd] %#",
str1];
NSLog(#"result==>%#",resultPredicate);
searchResults = [NSMutableArray arrayWithArray:[arr_search filteredArrayUsingPredicate:resultPredicate]];
}
array value for arr_search
arr_search ==>(
"Phoenix Market City",
"Express Avenue",
"Ampa Skywalk",
"The Forum Vijaya Mall",
"Chennai Citi Centre",
"Spencer Plaza",
"Chandra Metro Mall",
"The Grand Mall",
"Ramee Mall",
"Alsa Mall",
"Prince Plaza",
"Ispahani Centre",
"Fountain Plaza",
Lifestyle,
"Grand Venus Spectrum Mall",
"Raahat Palaza",
"Patni Plaza",
"Maya Plaza",
"Phoenix Mall, Chennai",
Megamart,
"Phoenix marketcity",
Aldo,
"Gokul Arcade",
"Parsn Complex",
"Spectrum mall",
"Express Avenue Chambers",
"Big Bazaar",
"Spencer's",
"Saravana Stores",
"CEX (complete entertainment exchange)"
)
I think it's typo error in this
NSPredicate *resultPredicate = [NSPredicate
predicateWithFormat:#"title tcontains[cd] %#",
str1];
It should be
NSPredicate *resultPredicate = [NSPredicate
predicateWithFormat:#"title contains[cd] %#",
str1];
Related
I am developing an iPhone app that is using the WCF to return data in json format. But when I am making call to the wcf service then I am getting the Error:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><s:Fault><faultcode xmlns:a="http://schemas.microsoft.com/ws/2005/05/addressing/none">a:ActionNotSupported</faultcode><faultstring xml:lang="en-US">The message with Action 'IPhoneDevService/GetConferenceIdByEventUrlName' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).</faultstring></s:Fault></s:Body></s:Envelope>
Service name : IPhoneDevService.svc there is no interface created for this.Same issue is comin g if I am using the Interface
Function :
[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceBehaviorAttribute(IncludeExceptionDetailInFaults = true)]
[DataContractFormat(Style = OperationFormatStyle.Document)]
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "IPhoneDevService" in code, svc and config file together.
public class IPhoneDevService
{
[WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest, RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Json)]
[OperationContract]
public string GetOneUserAuthentication(long confrenceid, string email, string password)
{
StringBuilder sbJson = new StringBuilder();
try
{
User[] objuserdetails = new User[1];
System.Nullable<short> strRet = 0;
string strRetMsg = string.Empty;
using (LINQTODBDataContext objDB = new LINQTODBDataContext())
{
objuserdetails = objDB.s_t_UserLoginVerifyClient(email, password, ref strRet, ref strRetMsg).Select(res => new User
{
UserID = res.UserId,
Message = ExceptionMsg.GetMessage(Convert.ToInt32(strRet), strRetMsg)
}).ToArray();
if (strRet == 2)
{
new JavaScriptSerializer().Serialize(objuserdetails, sbJson);
}
else
{
new JavaScriptSerializer().Serialize(ExceptionMsg.GetMessage(Convert.ToInt32(strRet), strRetMsg), sbJson);
}
}
}
catch (Exception ex)
{
return "";
}
return sbJson.ToString();
}
}
xcode consumption is:
NSString *soapMessage = [NSString stringWithFormat:#"<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\ <http://schemas.xmlsoap.org/soap/envelope/%5C>"><SOAP-ENV:Body><GetOneUserAuthentication><confrenceid>123</confrenceid><email>demo#abc.com <mailto:demo#abc.com></email><password>abc</password></GetOneUserAuthentication></SOAP-ENV:Body></SOAP-ENV:Envelope>"];
NSURL *url = [NSURL URLWithString:#"http://mydomain.com/IPhoneDevService.svc/basic"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:#"%d", [soapMessage length]];
[theRequest addValue: #"text/xml; charset=utf-8" forHTTPHeaderField:#"Content-Type"];
[theRequest addValue:#"IPhoneDevService/GetOneUserAuthentication" forHTTPHeaderField:#"SOAPAction"];
[theRequest addValue: msgLength forHTTPHeaderField:#"Content-Length"];
[theRequest setHTTPMethod:#"POST"];
[theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
Service Model of WCF webconfig is:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<bindings>
<basicHttpBinding>
<binding name="bhbinding" allowCookies="false">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true" />
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true" />
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false" />
<serviceThrottling maxConcurrentCalls="400" maxConcurrentInstances="400" maxConcurrentSessions="400" />
</behavior>
<behavior name="IphoneServiceBehaviour">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
<useRequestHeadersForMetadataAddress>
<defaultPorts>
<add scheme="http" port="8081" />
<add scheme="https" port="444" />
</defaultPorts>
</useRequestHeadersForMetadataAddress>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="Configurator_Service.IPhoneDevService" behaviorConfiguration="IphoneServiceBehaviour">
<endpoint address="basic" binding="basicHttpBinding" bindingConfiguration="bhbinding" contract="Configurator_Service.IPhoneDevService" />
</service>
</services>
</system.serviceModel>
It looks like you've configured your endpoint wrong.
In your WCF configuration you have:
<endpoint address="basic"
but in your XCode you specify
http://.../IPhoneDevService.svc
The endpoint address you specified in your configuration is going to look like:
http://.../IPhoneDevService.svc/basic
Typically, you just leave the endpoint address blank unless you need to have more than one (e.g. if you want to expose an MEX endpoint).
Debug shows me this
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
and the output shows
2013-05-16 04:58:07.496 Scroll Blog[5296:c07] get_recent_post&cat=
2013-05-16 04:58:12.251 Scroll Blog[5296:c07] -JSONValue failed. Error is: No digits in exponent
2013-05-16 04:58:12.252 Scroll Blog[5296:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
*** First throw call stack:
(0x28eb012 0x2207e7e 0x289eb6a 0x289ea20 0xb43c 0x12796 0xe3726 0x221b6b0 0x1c47765 0x286ef3f 0x286e96f 0x2891734 0x2890f44 0x2890e1b 0x28457e3 0x2845668 0x114bffc 0x2f3d 0x2e65 0x1)
libc++abi.dylib: terminate called throwing an exception
(lldb)
Try Adding an Exception Breakpoint. Now you should get a more useful stack trace.
I use this code to add events to the calendar app on iOS
int i = 0;
for(Schedule *sche in scheduleArray){
EKEventStore *eventStore=[[EKEventStore alloc] init];
EKEvent *addEvent=[EKEvent eventWithEventStore:eventStore];
addEvent.title=#"hello";
addEvent.startDate=[NSDate date];
addEvent.endDate=[addEvent.startDate dateByAddingTimeInterval:600];
[addEvent setCalendar:[eventStore defaultCalendarForNewEvents]];
addEvent.alarms=[NSArray arrayWithObject:[EKAlarm alarmWithAbsoluteDate:addEvent.startDate]];
NSError *err;
[eventStore saveEvent:addEvent span:EKSpanThisEvent error:&err];
if (err == nil) {
NSString* str = [[NSString alloc] initWithFormat:#"%#", addEvent.eventIdentifier];
NSLog(#"String %d: %#",i, str);
}
else {
NSLog(#"Error %#",err);
}
i++;
}
I want to add all events with data i saved before in scheduleArray, i have 86 object in scheduleArray, but it seem i only add about 82 events to calendar. Here is my log result:
.......
2013-02-19 14:04:28.237 MyDTUSchedule[5382:6607] String 67: BBCF7782-5D60-42D7-8478-EF80604FBF41:4A9E6404-B35B-4534-A7F2-5C6082F3D19A
2013-02-19 14:04:28.284 MyDTUSchedule[5382:6607] String 68: BBCF7782-5D60-42D7-8478-EF80604FBF41:47F0B6CF-3F98-49F9-B407-7A28B4F12C83
2013-02-19 14:04:28.343 MyDTUSchedule[5382:6607] String 69: BBCF7782-5D60-42D7-8478-EF80604FBF41:FB802E03-876D-4ADB-93B9-C3FAB628FF57
2013-02-19 14:04:28.412 MyDTUSchedule[5382:6607] String 70: BBCF7782-5D60-42D7-8478-EF80604FBF41:21786B81-BAC8-4979-9A04-B63CE404B870
2013-02-19 14:04:28.479 MyDTUSchedule[5382:6607] String 71: BBCF7782-5D60-42D7-8478-EF80604FBF41:9CF1DDA5-B8F3-4835-A5BC-A9FE745E17D1
2013-02-19 14:04:28.503 MyDTUSchedule[5382:6607] String 72: BBCF7782-5D60-42D7-8478-EF80604FBF41:834BE2CE-E810-4EA7-ACFC-01FAAA46453E
2013-02-19 14:04:28.580 MyDTUSchedule[5382:6607] String 73: BBCF7782-5D60-42D7-8478-EF80604FBF41:BFBDBECF-1A31-4363-9FD2-66C05F4085B9
2013-02-19 14:04:28.629 MyDTUSchedule[5382:6607] String 74: BBCF7782-5D60-42D7-8478-EF80604FBF41:3512265D-10A9-40AE-8435-0BDBC1D72A1B
2013-02-19 14:04:28.690 MyDTUSchedule[5382:6607] String 75: BBCF7782-5D60-42D7-8478-EF80604FBF41:96C68CAC-2955-4EDD-8FE2-442CDDDE39A8
2013-02-19 14:04:28.733 MyDTUSchedule[5382:6607] String 76: BBCF7782-5D60-42D7-8478-EF80604FBF41:2724EBFD-AB03-4E6A-8094-25D7035B517C
2013-02-19 14:04:28.818 MyDTUSchedule[5382:6607] String 77: BBCF7782-5D60-42D7-8478-EF80604FBF41:CC14386F-E21A-41AA-82D5-42B05149EB09
2013-02-19 14:04:28.865 MyDTUSchedule[5382:6607] String 78: BBCF7782-5D60-42D7-8478-EF80604FBF41:3738B384-21B9-4544-8DD2-C50032B5404D
2013-02-19 14:04:28.929 MyDTUSchedule[5382:6607] String 79: BBCF7782-5D60-42D7-8478-EF80604FBF41:70F820A8-37A5-4CC1-8E0E-696736CABC2C
2013-02-19 14:04:28.964 MyDTUSchedule[5382:6607] String 80: BBCF7782-5D60-42D7-8478-EF80604FBF41:864E4DEF-275F-4458-A5E2-A136C2F57982
2013-02-19 14:04:29.019 MyDTUSchedule[5382:6607] String 81: BBCF7782-5D60-42D7-8478-EF80604FBF41:061BF4AE-6BD5-4B3E-B2FC-35A18A7D99A5
2013-02-19 14:04:29.042 MyDTUSchedule[5382:6607] Error Error Domain=EKErrorDomain Code=1 "No calendar has been set." UserInfo=0xe21da30 {NSLocalizedDescription=No calendar has been set.}
2013-02-19 14:04:29.052 MyDTUSchedule[5382:6607] Error Error Domain=EKErrorDomain Code=1 "No calendar has been set." UserInfo=0xe1551d0 {NSLocalizedDescription=No calendar has been set.}
2013-02-19 14:04:29.054 MyDTUSchedule[5382:6607] Error Error Domain=EKErrorDomain Code=1 "No calendar has been set." UserInfo=0xe21bf90 {NSLocalizedDescription=No calendar has been set.}
2013-02-19 14:04:29.058 MyDTUSchedule[5382:6607] Error Error Domain=EKErrorDomain Code=1 "No calendar has been set." UserInfo=0xe21abd0 {NSLocalizedDescription=No calendar has been set.}
I don't know why these errors happen? How can i add all my events to the calendar?
I want to get the data between tag, from xml, using NSRegularExpression
This is the xml
<?xml version="1.0" encoding="UTF-8"?>
<document xmlns="#link" xmlns:xsi="#link" xsi:schemaLocation="#link" version="1.0">
<field left="493" top="670" right="1550" bottom="760" type="text">
<value encoding="utf-16">JENNIFER mml</value>
<line left="493" top="670" right="1550" bottom="733">
<char left="493" top="670" right="549" bottom="733" confidence="69">J</char>
<char left="565" top="670" right="605" bottom="718" confidence="71" suspicious="true">E</char>
<char left="623" top="670" right="660" bottom="718" confidence="76">N</char>
<char left="678" top="670" right="720" bottom="722" confidence="56">N</char>
<char left="736" top="674" right="776" bottom="730" confidence="80">I</char>
<char left="804" top="674" right="841" bottom="729" confidence="74">F</char>
<char left="858" top="670" right="902" bottom="725" confidence="80">E</char>
<char left="922" top="670" right="964" bottom="730" confidence="86">R</char>
<char left="965" top="670" right="1442" bottom="730" confidence="100" />
<char left="1443" top="685" right="1495" bottom="720" confidence="2" suspicious="true">m</char>
<char left="1492" top="685" right="1534" bottom="719" confidence="11" suspicious="true">m</char>
<char left="1544" top="685" right="1550" bottom="718" confidence="100" suspicious="true">l</char>
</line>
</field>
</document>
I want extract this data, between the value tag
<value encoding="utf-16">JENNIFER mml</value>
This is the ios code
NSString *xml =#"<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?><document xmlns=\"#link\" xmlns:xsi=\"#link\" xsi:schemaLocation=\"#link\" version=\"1.0\"><field left=\"493\" top=\"670\" right=\"1550\" bottom=\"760\" type=\"text\"><value encoding=\"utf-16\">JENNIFER mml</value><line left=\"493\" top=\"670\" right=\"1550\" bottom=\"733\"><char left=\"493\" top=\"670\" right=\"549\" bottom=\"733\" confidence=\"69\">J</char><char left=\"565\" top=\"670\" right=\"605\" bottom=\"718\" confidence=\"71\" suspicious=\"true\">E</char><char left=\"623\" top=\"670\" right=\"660\" bottom=\"718\" confidence=\"76\">N</char><char left=\"678\" top=\"670\" right=\"720\" bottom=\"722\" confidence=\"56\">N</char><char left=\"736\" top=\"674\" right=\"776\" bottom=\"730\" confidence=\"80\">I</char><char left=\"804\" top=\"674\" right=\"841\" bottom=\"729\" confidence=\"74\">F</char><char left=\"858\" top=\"670\" right=\"902\" bottom=\"725\" confidence=\"80\">E</char><char left=\"922\" top=\"670\" right=\"964\" bottom=\"730\" confidence=\"86\">R</char><char left=\"965\" top=\"670\" right=\"1442\" bottom=\"730\" confidence=\"100\"> </char><char left=\"1443\" top=\"685\" right=\"1495\" bottom=\"720\" confidence=\"2\" suspicious=\"true\">m</char><char left=\"1492\" top=\"685\" right=\"1534\" bottom=\"719\" confidence=\"11\" suspicious=\"true\">m</char><char left=\"1544\" top=\"685\" right=\"1550\" bottom=\"718\" confidence=\"100\" suspicious=\"true\">l</char></line></field></document>";
NSString *pattern = #"<value>(\\d+)</value>";
NSRegularExpression *regex = [NSRegularExpression
regularExpressionWithPattern:pattern
options:NSRegularExpressionCaseInsensitive
error:nil];
NSTextCheckingResult *textCheckingResult = [regex firstMatchInString:xml options:0 range:NSMakeRange(0, xml.length)];
NSRange matchRange = [textCheckingResult rangeAtIndex:1];
NSString *match = [xml substringWithRange:matchRange];
NSLog(#"Found string '%#'", match);
Your current regex only matches a precise <value> tag and a number with \d+.
<value>(\d+)</value>
However, your input has an attribute (encoding="utf-16") and doesn't contain a number as the value (JENNIFER mml):
<value encoding="utf-16">JENNIFER mml</value>
To overcome the first issue, you can either hardcode the attribute into the regex, or modify the pattern slightly:
<value encoding="utf-16">
or
<value[^>]*>
To match the value of the tag, as it appears to be alphabetical (with whitespace), and we'll throw in numbers too, you could use:
[a-zA-Z0-9\s]+
So, altogether you could try:
<value[^>]*>([a-zA-Z0-9\s]+)</value>
With your current code (for copy+paste):
NSString *pattern = #"<value[^>]*>([a-zA-Z0-9\\s]+)</value>";
UPDATE (anything can match between <value></value>)
Per a comment, the exact text between the <value></value> tags can contain any character, not just alphanumeric. To handle this, we can just match everything with (.*):
<value>[^>]*>(.*)</value>
With your current code:
NSString *pattern = #"<value[^>]*>(.*)</value>";
I am creating an iphone app with xmpframework, everything works fine, but i would like to update my profile picture with the following code. and i got some incorrect recursive vCard-temp request to the server. But the picture got updated, and notified all friends in my roster.
//I clicked on the button
-(void)updatevCardButtonClicked{
XMPPvCardTemp *vCardTemp = [[[self appDelegate] xmppvCardTempModule] myvCardTemp];
NSLog(#"my vCardTemp: %#", vCardTemp);
NSData *tempImage = [self getDataFromImage:[self resizeImage:userImage]];
[vCardTemp setPhoto: tempImage];
[[[self appDelegate] xmppvCardTempModule]updateMyvCardTemp:vCardTemp];
}
output and explanation below
my vCardTemp: *nil description*
MyApp[60625:6c1b] XMPPvCardCoreDataStorage: Triggering save (pendingRequests=0)
MyApp[60625:207] MyAppDelegate: xmppStream:didReceiveIQ: - E49C843A-5A05-4148-A4CF-B400062A83C0
MyApp[60625:207] MyAppDelegate: xmppStream:didReceivePresence: - <presence xmlns="jabber:client" from="myJabberAccount#127.0.0.1/1948110991326183732515886" to="myJabberAccount#127.0.0.1/1948110991326183732515886">
<status>At work</status>
<x xmlns="vcard-temp:x:update">
<photo>1f6401ddea76826fddc4cd7ddc17741db6c9dabc</photo>
</x>
<c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="http://code.google.com/p/xmppframework" ver="VyOFcFX6+YNmKssVXSBKGFP0BS4="></c>
<x xmlns="vcard-temp:x:update">
<photo>c3b2d65259a4fc1d37e56777697d4f5a9730fb03</photo></x><c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="http://code.google.com/p/xmppframework" ver="VyOFcFX6+YNmKssVXSBKGFP0BS4="></c>
</presence>
MyApp[60625:5323] XMPPRosterCoreDataStorage: handlePresence:xmppStream:
//repeat start from here, and the DidReceivePresence: will grow into tons of lines with the samthing
MyApp[60625:207] XMPPRosterCoreDataStorage: userForJID:xmppStream:managedObjectContext:
MyApp[60625:1e0b] XMPPRosterCoreDataStorage: userForJID:xmppStream:managedObjectContext:
MyApp[60625:207] XMPPRosterCoreDataStorage: resourceForJID:xmppStream:managedObjectContext:
MyApp[60625:5323] XMPPvCardCoreDataStorage: Triggering save (pendingRequests=0)
MyApp[60625:207] MyAppDelegate: xmppStream:didReceiveIQ: - (null)
MyApp[60625:1e0b] XMPPvCardCoreDataStorage: Triggering save (pendingRequests=0)
MyApp[60625:207] MyAppDelegate: xmppStream:didReceivePresence: - <presence xmlns="jabber:client" from="myJabberAccount#127.0.0.1/1948110991326183732515886" to="myJabberAccount#127.0.0.1/1948110991326183732515886">
<status>At work</status>
<x xmlns="vcard-temp:x:update">
<photo>1f6401ddea76826fddc4cd7ddc17741db6c9dabc</photo>
</x>
<c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="http://code.google.com/p/xmppframework" ver="VyOFcFX6+YNmKssVXSBKGFP0BS4="></c>
<x xmlns="vcard-temp:x:update">
<photo>c3b2d65259a4fc1d37e56777697d4f5a9730fb03</photo>
</x>
<c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="http://code.google.com/p/xmppframework" ver="VyOFcFX6+YNmKssVXSBKGFP0BS4="></c>
<x xmlns="vcard-temp:x:update">
<photo>c3b2d65259a4fc1d37e56777697d4f5a9730fb03</photo>
</x>
<c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="http://code.google.com/p/xmppframework" ver="VyOFcFX6+YNmKssVXSBKGFP0BS4=">
</c>
</presence>
//repeat the above in the rest of the output with more and more "vcard-temp:x:update"
what i found so far, the below cause this problem, but i can't figure out where i can fix it.
//i found that these two "SEND" cause the problem, the app just keep sending these two
SEND: <iq type="get" to="myJabberAccount#127.0.0.1"><vCard xmlns="vcard-temp"/></iq>
SEND: <presence>
<x xmlns="vcard-temp:x:update">
<photo>1f6401ddea76826fddc4cd7ddc17741db6c9dabc</photo>
</x>
<c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="http://code.google.com/p/xmppframework" ver="VyOFcFX6+YNmKssVXSBKGFP0BS4="/>
<x xmlns="vcard-temp:x:update">
<photo>1f6401ddea76826fddc4cd7ddc17741db6c9dabc</photo>
</x>
<c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="http://code.google.com/p/xmppframework" ver="VyOFcFX6+YNmKssVXSBKGFP0BS4="/>
<x xmlns="vcard-temp:x:update">
<photo>f93ee3918c7baaf095edb9f6bede892c603161af</photo>
</x>
<c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="http://code.google.com/p/xmppframework" ver="VyOFcFX6+YNmKssVXSBKGFP0BS4="/>
<x xmlns="vcard-temp:x:update">
<photo>f93ee3918c7baaf095edb9f6bede892c603161af</photo>
</x>
<c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="http://code.google.com/p/xmppframework" ver="VyOFcFX6+YNmKssVXSBKGFP0BS4="/>
</presence>
//this presence keep growing as you can see the repeated parts
I have been trying to tackle this problem for quite some time. Let me know if this works for you. Here's my explanation:
Whenever you send a presence element via xmppStream, it caches a copy of it under the "myPresence" instance variable.
If you look for the following method in XMPPStream.m:
- (void)continueSendElement:(NSXMLElement *)element withTag:(long)tag
there is a comment about 10-20 lines down that says:
// Update myPresence if this is a normal presence element.
// In other words, ignore presence subscription stuff, MUC room stuff, etc.
When the XMPPvCardAvatarModule class updates the vcard, it introduces things like the <x> and the <c> (capability) tags that pollutes the normal presence element.
To fix this, we need to clean up those unnecessary tags. Here is a section of my edited code:
else if ([element isKindOfClass:[XMPPPresence class]])
{
// Update myPresence if this is a normal presence element.
// In other words, ignore presence subscription stuff, MUC room stuff, etc.
XMPPPresence *presence = (XMPPPresence *)element;
// We use the built-in [presence type] which guarantees lowercase strings,
// and will return #"available" if there was no set type (as available is implicit).
NSString *type = [presence type];
if ([type isEqualToString:#"available"] || [type isEqualToString:#"unavailable"])
{
NSArray *vCardXElem = [presence elementsForName:#"x"];
NSArray *capabilitiesHash = [presence elementsForName:#"c"];
for (NSXMLElement *x in vCardXElem)
{
[presence removeChildAtIndex:[x index]];
}
for (NSXMLElement *c in capabilitiesHash)
{
[presence removeChildAtIndex:[c index]];
}
if ([presence toStr] == nil && myPresence != presence)
{
myPresence = presence;
}
}
[multicastDelegate xmppStream:self didSendPresence:(XMPPPresence *)element];
}