In the development of this error, breakpoint lookup for a long time, did not find the code of the problem, Google, found below these points will produce this error:
- First, as the name implies, the reason for the error is that when we call a method, we pass in an empty string (note that the string content is different from null) as a method parameter.
- Use the Objectatindex method for an empty array. Do not count off the cross-section of the error, but Nsscanner:nil string argument.
After checking, my code if the string assignment, I generally do a certain processing of nil, with @ "" instead of the array out of bounds, but still reported such errors.
Now the information point is libc++abi.dylib, What exactly does this library do? From the suffix view, is a dynamic library, then will it be because of some dynamic errors? By experience, the general dynamic error is basically due to the dynamic type error, in the Object-c language, the possibility of a dynamic type error can exist in the transformation between the immutable type and the mutable type, then our error-checking scope will be limited to the immutable type and the variable type conversion, Are we modifying a immutable type? Of course, the compiler is not so silly, if directly to an immutable type modification operation, will be directly error, then there is another possibility, the program assigns an immutable type to a mutable type, and then modifies the mutable type, which can be checked by static, but dynamically run, A type error occurs. Based on the above analysis, we can track breakpoints, we will find that the program in the Mutable object to add, set and other operations, and this object is actually assigned to an immutable object. A common case is to assign a Nsarray object to a Nsmutablearray object, then delete, add, and so on, or assign a Nsdictionary object to a Nsmutabledictionary object. Then the set and other operations are performed.
This is the solution from the http://www.itnose.net/detail/6196671.html, after the investigation, the code on the surface also did not have such a mistake.
Then find the breakpoint code at the end of the crash as follows:
Nsdictionary *orderdict = [notification userInfo]; Self.selectedorderdict = orderdict; Nsindexpath *indexpath = [Nsindexpath indexPathForRow:self.selectedRow insection:0]; [Self.tableview Reloadrowsatindexpaths:[nsarray Arraywithobjects:@[indexpath], nil] withrowanimation: Uitableviewrowanimationnone];
Brainwave, actually do not know how to change, so changed to the following code, and then compile, run, since it is possible ...
Nsdictionary *orderdict = [notification userInfo]; Self.selectedorderdict = orderdict; Nsindexpath *indexpath = [Nsindexpath indexPathForRow:self.selectedRow insection:0]; Nsmutablearray *tmparray = [Nsmutablearray array]; [Tmparray Addobject:indexpath]; [Self.tableview Reloadrowsatindexpaths:tmparray Withrowanimation:uitableviewrowanimationnone];
Puzzled, since this can be, but from the code level, the logical level, these two should be the same way, is this an excuse to need a mutable array? Then open the inside of the interface, found that this is:
-(void) Reloadrowsatindexpaths: (Nsarray *) indexpaths withrowanimation: (uitableviewrowanimation) Animation NS_ Available_ios (3_0);
At that time, my mood was broken, and then, what do you mean, then have the following test:
Nsdictionary *orderdict = [notification userInfo]; Self.selectedorderdict = orderdict; Nsindexpath *indexpath = [Nsindexpath indexPathForRow:self.selectedRow insection:0];//nsmutablearray *tmparray = [Nsmutablearray array];// [Tmparray addobject:indexpath];// [Self.tableview reloadrowsatindexpaths: Tmparray Withrowanimation:uitableviewrowanimationnone]; Nsarray *tmparray = @[indexpath]; [Self.tableview Reloadrowsatindexpaths:tmparray Withrowanimation:uitableviewrowanimationnone];
This also does not collapse ...
Well, to this, although the mistake has been solved, but did not find the corresponding reason, I do not understand ... Why
Nsarray *tmparray = @[indexpath]; [Self.tableview Reloadrowsatindexpaths:tmparray Withrowanimation:uitableviewrowanimationnone];
So write, not error, not crash, and like the first code to write, it crashes? If a friend has an answer, please answer it.
Solution for Nsscanner:nil string argument Libc++abi.dylib:terminat error is synthesized