Tuesday, 15 March 2011

ios - Content-Type JSON SIGABRT Error -



ios - Content-Type JSON SIGABRT Error -

i trying parse json, , getting sigabrt error: reason: '[<nsurlrequest 0x7e7e970> setvalue:forundefinedkey:]: class not key value coding-compliant key content-type.

my code is:

self.responsedata = [nsmutabledata data]; nsurlrequest *request = [nsurlrequest requestwithurl: [nsurl urlwithstring:@"http://dmsfw01.dev.com:8082/g.fqi/gvolfqi.svc/search(v)?start=1&count=10"]]; nsstring *contenttype = @"application/json"; [request setvalue:contenttype forkey:@"content-type"]; [[nsurlconnection alloc] initwithrequest:request delegate:self];

what should instead set content-type?

you getting error because using key value coding method tries set property on request name content-type. can not modify nsurlrequest because immutable. utilize nsmutableurlrequest instead , phone call - (void)setvalue:(nsstring *)value forhttpheaderfield:(nsstring *)field.

nsmutableurlrequest *request = [nsmutableurlrequest requestwithurl: [nsurl urlwithstring:@"http://sw730voldmsfw01.vol1dev.com:8082/gvol.fqi/gvolfqi.svc/search(visa)?start=1&count=10"]]; nsstring *contenttype = @"application/json"; [request setvalue:contenttype forhttpheaderfield:@"content-type"];

ios objective-c json nsurlrequest

No comments:

Post a Comment