ios - Why is crashed in NSRangeException? -
i parse xml string xmldictionary https://github.com/nicklockwood/xmldictionary . have code:
nsurl *url = [[nsurl alloc] initwithstring:[self.rssfeed objectatindex:i]]; nsstring *xmlstring = [[nsstring alloc] initwithcontentsofurl:url encoding:nsutf8stringencoding error:null]; nsdictionary *xmldoc = [nsdictionary dictionarywithxmlstring:xmlstring]; nsmutablearray *aux = [[nsmutablearray alloc]initwitharray:[[xmldoc valueforkey:@"channel"]valueforkey:@"item"]];
and crashed @ line:
nsstring *xmlstring = [[nsstring alloc] initwithcontentsofurl:url encoding:nsutf8stringencoding error:null];
with error:
terminating app due uncaught exception 'nsrangeexception', reason: '*** -[__nsarraym objectatindex:]: index 5 beyond bounds empty array'
have ideas? curious: app not crashed every time when running code. part of method performselectorinbackground. think value changing
actually, reckon it's crashing on line before:
nsurl *url = [[nsurl alloc] initwithstring:[self.rssfeed objectatindex:i]];
put breakpoint on line, , see how many items in self.rssfeed
array...
(spoiler alert: array empty.)
good luck.
Comments
Post a Comment