NSRangeException : "beyond bounds" error
I am working on a sqlite-based application in the database of which there is a field at index 2开发者_开发问答.
In this I am not saving any data but when I run that database on Firefox I see that the index 2 had a value -2147483648, and when I am trying to add a new cell in my subview by:
return [appDelegate.items count]+1;
I am getting this error:
Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSCFArray objectAtIndex:]: index (2) beyond bounds (2)'
The variable at index 2 is of decimal type:-
NSInteger n = i.need;
and...
sqlite3_bind_int(updStmt, 2, n);
...is the default value coming in index 2. Does this have to do anything with the exception? If yes, how can I can correct it and if no then why is it happening?
I think you are using access Specifier %@
instead of %d
while inserting or reading...
Use intValue for retriving or inserting.
精彩评论