objective c - Consuming services in iOS 9.0 -
i have implemented following code consuming servives in ios.
nsstring *urlstr=[nsstring stringwithformat:@“someurl”]; nsstring *jsonstr=[nsstring stringwithformat:@“{\”someparameter\”:\”%@\”}”]; nsdata *postdata = [jsonstr datausingencoding:nsutf8stringencoding allowlossyconversion:yes]; nsstring *postlength = [nsstring stringwithformat:@"%lu", (unsigned long)[postdata length]]; nsmutableurlrequest *request = [[nsmutableurlrequest alloc] init]; [request seturl:[nsurl urlwithstring:urlstr]]; [request sethttpmethod:@"post"]; [request setvalue:postlength forhttpheaderfield:@"content-length"]; [request setvalue:@"application/json;charset=utf-8" forhttpheaderfield:@"content-type"]; [request sethttpbody:postdata]; nsurlresponse *response; nsdata *postreply = [nsurlconnection sendsynchronousrequest:request returningresponse:&response error:nil]; nsstring *thereply = [[nsstring alloc] initwithbytes:[postreply bytes] length:[postreply length] encoding: nsutf8stringencoding]; sbjson *parser = [[sbjson alloc] init]; nsarray *arryterritory = (nsarray *) [parser objectwithstring:thereply error:nil]; nslog(@“%@”,[arryterritory description]);
this code when run code xcode 6.4 , ios 9.0 able receive data in nsdata *postdata
, nsstring *postlength
.
but while compiling code ios 9.0 unable data.
output nil
.
is there different process consume services in xcode 7 beta. need ipa compatible these versions.
here should add deceleration info.plist needs secure communication. code added info.plist.i think new in ios 9 , xcode 7 bete versions.
<key>nsapptransportsecurity</key> <dict> <key>nsallowsarbitraryloads</key> <true/> </dict>
Comments
Post a Comment