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

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -