ios - How can I protect myself from this crash *** -[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0]? -
the below code shows have, crash occurs on line ' class = [mpagedataarray objectatindex:mpageindex];'
if (mpageindex > mpagedataarray.count || mpageindex < 0) return; class = [mpagedataarray objectatindex:mpageindex];
i don't know how else can prevent crash. 1 user experienced , trying create app crash free possible.
do :
if (mpageindex >= mpagedataarray.count || mpageindex < 0) return; class = [mpagedataarray objectatindex:mpageindex];
because count
total object in array. if there 1 object, count
homecoming 1, index object 0
here crash, because have 1 object in array, looking @ index 1 (which index sec object)
ios objective-c iphone arrays crash
No comments:
Post a Comment