Getting error in this line :
NSString *nmm =[narr objectAtIndex:1];
error shows :
'NSRangeException', reason: '*** -[NSCFArray objectAtIndex:]: index (1) beyond bounds (1)'
开发者_运维知识库
It looks like your array only got one value (which you can accesss at index 0, not index 1).
You should probably start by checking the contents of narr at run time. It sounds like the contents aren't what you would expect them to be at the desired point in execution. Right before the line you posted in your question, use an NSLog call to log the contents of the array like this:
NSLog(@"Contents of array: %@", narr);
Then run the app and check the console after the error arises. Put some time into learning how to use NSLog, breakpoints, and the GDB console - they will end up saving you lots of frustration when debugging.
Your comments on unset's answer raise another point: Why are you storing multiple pieces of data inside the same string? Wouldn't it be easier to separate name
, lname
and id
into separate strings and place each into its own array cell? Then you could access them using [narr objectAtIndex:]
without having to worry about parsing the string every time you need one of those pieces of information.
精彩评论