objective c - Update AFNetworking from version 1.2.1 to 3.1.0 -
iam update our post project in objective c meet new apple requirement support ipv6 only. afnetworking libray 1.2.1. doubt problem. want update latest version support ipv6 when running pod install error
[!] unable satisfy following requirements:
afnetworking (~> 3.1.0)requiredpodfileafnetworking (= 3.1.0)requiredpodfile.lockafnetworking (~> 1.2.1)requiredafrapturexmlrequestoperation (1.0.2)
here complete pod file
platform :ios, '7.0' def shared_pods pod 'rapturexml' pod 'realm' end def ios_pods pod 'afrapturexmlrequestoperation' pod 'googleanalytics-ios-sdk', '~> 3.0.9' pod 'kgmodal', '~> 0.0.1' pod 'magicalrecord' pod 'mhnatgeoviewcontrollertransition', '~> 1.0' pod 'svprogresshud', '~> 1.0' pod 'ualogger', '~> 0.2.3' pod 'reachability', '~> 3.1.1' pod 'regexkitlite', '~> 4.0' pod 'sskeychain', '~> 1.2.1' pod 'tttattributedlabel' pod 'tpkeyboardavoiding', '~> 1.1' pod 'uialertview+blocks', '~> 0.7' pod 'uiactivityindicator-for-sdwebimage', '~> 1.0.3' pod 'sevenswitch', '~> 1.3.0' pod 'zxingobjc', '~> 3.0' pod 'deviceutil', '~> 1.2' end is there way use afrapturexmlrequestoperation afnetworking 3.0? or other solution? appreciate. thanks
afrapturexmlrequestoperation subclasses afhttprequestoperation, class no longer exists in afnetworking 3.x. not able use afrapturexmlrequestoperation afnetworking 3.x.
if you're parsing xml response afnetworking 3.x, can use afxmlparserresponseserializer. returns nsxmlparser.
so, set delegate responseobject, , call parse on it:
afhttpsessionmanager *manager = [afhttpsessionmanager manager]; manager.responseserializer = [afxmlparserresponseserializer serializer]; manager.responseserializer.acceptablecontenttypes = [manager.responseserializer.acceptablecontenttypes setbyaddingobject:@"application/rss+xml"]; // line needed if parsing rss feed [manager get:@"https://developer.apple.com/news/rss/news.rss" parameters:nil progress:nil success:^(nsurlsessiondatatask * _nonnull task, id _nullable responseobject) { nsxmlparser *parser = responseobject; parser.delegate = self; self.titles = [nsmutablearray array]; [parser parse]; nslog(@"%@", self.titles); } failure:^(nsurlsessiondatatask * _nullable task, nserror * _nonnull error) { nslog(@"%@", error); }]; you'll have write own nsxmlparserdelegate code, though. so, parse titles out of xml of apple's rss feed, added 2 properties:
@property (nonatomic, strong) nsmutablearray *titles; @property (nonatomic, strong) nsmutablestring *elementvalue; and implemented following nsxmlparserdelegate methods:
- (void)parser:(nsxmlparser *)parser didstartelement:(nsstring *)elementname namespaceuri:(nsstring *)namespaceuri qualifiedname:(nsstring *)qname attributes:(nsdictionary<nsstring *,nsstring *> *)attributedict { if ([elementname isequaltostring:@"title"]) { self.elementvalue = [nsmutablestring string]; } } - (void)parser:(nsxmlparser *)parser foundcharacters:(nsstring *)string { [self.elementvalue appendstring:string]; } - (void)parser:(nsxmlparser *)parser didendelement:(nsstring *)elementname namespaceuri:(nsstring *)namespaceuri qualifiedname:(nsstring *)qname { if ([elementname isequaltostring:@"title"]) { [self.titles addobject:self.elementvalue]; self.elementvalue = nil; } }
Comments
Post a Comment