ios - Better way to get BOOL from ColdFusion boolean return type in Objective-C? -


i have method in app sends request server check if user logged in. coldfusion function returns type boolean. when nslog data returned, get:

<wddxpacket version='1.0'><header/><data><boolean value='true'/></data></wddxpacket>.

currently, determine if returned true or false i'm searching substring 'true' in returned string. not seem solution. question is, there better way objective-c bool function? if it's better change coldfusion function, luckily can that. thanks!

coldfusion function:

<cffunction name="loggedin" returntype="boolean" output="false" access="remote">     <cfargument name="sessionid" type="uuid" required="true">     <cfquery name="q_session" datasource="#request.db_dsn#">         select ...     </cfquery>     <cfreturn q_session.recordcount gte 1> </cffunction> 

objective-c method snippet:

    nsmutableurlrequest *request = [[nsmutableurlrequest alloc] init];     [request seturl:myurlvar];     [request sethttpmethod:@"post"];     [request setvalue:@"application/x-www-form-urlencoded" forhttpheaderfield:@"content-type"];     [request setvalue:postlength forhttpheaderfield:@"content-length"];     [request setvalue:@"application/json" forhttpheaderfield:@"accept"];     [request sethttpbody:postdata];      nserror *requesterror = [[nserror alloc] init];     nshttpurlresponse *response = nil;     nsdata *urldata = [nsurlconnection sendsynchronousrequest:request                                             returningresponse:&response                                                         error:&requesterror];      nsstring *responsedata = [[nsstring alloc]initwithdata:urldata encoding:nsutf8stringencoding];     nslog(@"%@", responsedata);     if ([responsedata rangeofstring:@"true" options:nscaseinsensitivesearch].location != nsnotfound){         sessionisactive = yes;     } 

i think can add returnformat="plain" cffunction.

plain: ensure return value type coldfusion can convert directly string, , return string value without serialization. valid types include simple types, such numbers, , xml objects. if return value complex type, such array, or binary value, coldfusion generates error. if specify returntype attribute, value must any, boolean, date, guid, numeric, string, uuid, variablename, or xml; otherwise, coldfusion generates error.

by default, coldfusion serializes return types (including simple return types), except xml, wddx format, , returns xml data xml text.

that should give string, simpler parse.

[source]


Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -