老項目突然出現(xiàn)這個crash覆积,當初開發(fā)的時候并未沒報這個錯,猜測應該是Xcode升級后的事兒咕别,當然問題根源還是在代碼上技健。
源代碼:
1、用xib創(chuàng)建UITableViewCell:testTableViewCell.xib
2惰拱、UITableView注冊cell:[tableView registerNib:[UINib nibWithNibName:@“testTableViewCell” bundle:nil] forCellReuseIdentifier:@“identifier2”];
3雌贱、復用池獲取cell: UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"identifier2"];
報錯日志:
Exception name:NSInternalInconsistencyException
Exception reason:cell reuse indentifier in nib (identifier1) does not match the identifier used to register the nib (identifier2)
Exception stack :[
0 CoreFoundation 0x000000018151ae14 B04B698D-3699-38CA-8A94-62CB458C8F89 + 855572,
1 libobjc.A.dylib 0x000000019852e0d8 objc_exception_throw + 56,
2 Foundation 0x0000000182c6de88 0EA4BB66-BF72-355F-A4A0-F27AA1B7CB22 + 1109640,
3 UIKitCore 0x000000018382c408 998657EE-5337-3100-9165-1E387EDCF5DD + 877576,
4 UIKitCore 0x00000001838a044c 998657EE-5337-3100-9165-1E387EDCF5DD + 1352780,
5 TestApp 0x0000000102c6bbf0 -[viewController tableView:cellForRowAtIndexPath:] + 272,
6 UIKitCore 0x000000018389e878 998657EE-5337-3100-9165-1E387EDCF5DD + 1345656,
7 UIKitCore 0x00000001846c3634 998657EE-5337-3100-9165-1E387EDCF5DD + 16176692,
8 UIKitCore 0x0000000183856998 998657EE-5337-3100-9165-1E387EDCF5DD + 1051032,
9 UIKitCore 0x000000018385643c 998657EE-5337-3100-9165-1E387EDCF5DD + 1049660,
10 UIKitCore 0x0000000183759c70 998657EE-5337-3100-9165-1E387EDCF5DD + 15472,
11 QuartzCore 0x0000000184ebd518 66B39605-0B88-3A9A-ACFD-76BFCFC78C4F + 17688,
12 QuartzCore 0x0000000184ecb02c 66B39605-0B88-3A9A-ACFD-76BFCFC78C4F + 73772,
13 QuartzCore 0x0000000184ef2fdc 66B39605-0B88-3A9A-ACFD-76BFCFC78C4F + 237532,
14 QuartzCore 0x0000000184f2c698 66B39605-0B88-3A9A-ACFD-76BFCFC78C4F + 472728,
15 QuartzCore 0x000000018506f42c 66B39605-0B88-3A9A-ACFD-76BFCFC78C4F + 1795116,
16 CoreFoundation 0x00000001814ca374 B04B698D-3699-38CA-8A94-62CB458C8F89 + 525172,
17 CoreFoundation 0x000000018145c2a4 B04B698D-3699-38CA-8A94-62CB458C8F89 + 74404,
18 CoreFoundation 0x00000001814b7f4c B04B698D-3699-38CA-8A94-62CB458C8F89 + 450380,
19 CoreFoundation 0x00000001814c4ddc CFRunLoopRunSpecific + 572,
20 GraphicsServices 0x000000019b548afc GSEventRunModal + 160,
21 UIKitCore 0x0000000183b06d70 998657EE-5337-3100-9165-1E387EDCF5DD + 3870064,
22 UIKitCore 0x0000000183b067f8 UIApplicationMain + 2140,
23 TestApp 0x0000000102f2f3bc main + 120,
24 dyld 0x0000000105ad11d0 start + 444
]
libc++abi: terminating with uncaught exception of type NSException
dyld4 config: DYLD_LIBRARY_PATH=/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/Developer/usr/lib/libBacktraceRecording.dylib:/Developer/usr/lib/libMainThreadChecker.dylib:/Developer/Library/PrivateFrameworks/GPUTools.framework/libglInterpose.dylib:/usr/lib/libMTLCapture.dylib:/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'cell reuse indentifier in nib (identifier1) does not match the identifier used to register the nib (identifier2)’
terminating with uncaught exception of type NSException
報錯原因:
- (void)registerNib:(nullable UINib *)nib forCellReuseIdentifier:(NSString *)identifier;
- (nullable __kindof UITableViewCell *)dequeueReusableCellWithIdentifier:(NSString *)identifier;
說是上面兩個方法中的identifier值不一致。
可是源代碼里面的identifier值明明是一樣的identifier2
偿短,那這identifier1
哪兒冒出來的欣孤,猜想應該是自己在某個地方手動寫入的,最后順著這個值找到原來是xib文件里面的配置出了問題:
清空這個identifier屬性值就OK了昔逗!
只能以兩個不同identifier沖突來解釋了降传。