-1
我們這沒有任何問題的工作中的iOS 7的應用程序,但在iOS 8運行時,出現以下錯誤崩潰:UIPickerView拋出 - [__ NSArrayM objectAtIndex:]:索引0超出界限時,數據源是不是在iOS的空8
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** - [__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'
*** First throw call stack:
(
0 CoreFoundation 0x03361df6 __exceptionPreprocess + 182
1 libobjc.A.dylib 0x026fca97 objc_exception_throw + 44
2 CoreFoundation 0x03238073 -[__NSArrayM objectAtIndex:] + 243
3 eAlth Devel 0x0022f13e -[NSArray(TKCategory) firstObject] + 62
4 UIKit 0x00f411ee -[UITableView reloadData] + 443
5 UIKit 0x00f45ede -[UITableView _reloadDataIfNeeded] + 78
6 UIKit 0x00f4bec7 -[UITableView layoutSubviews] + 36
7 UIKit 0x00ec19c0 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 608
8 libobjc.A.dylib 0x02712771 -[NSObject performSelector:withObject:] + 70
9 QuartzCore 0x0055a27f -[CALayer layoutSublayers] + 152
10 QuartzCore 0x0054e105 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 397
11 QuartzCore 0x0054df60 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
12 QuartzCore 0x004ac676 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 284
13 QuartzCore 0x004ada3c _ZN2CA11Transaction6commitEv + 392
14 QuartzCore 0x004ae108 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
15 CoreFoundation 0x03284fbe __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
16 CoreFoundation 0x03284f00 __CFRunLoopDoObservers + 400
17 CoreFoundation 0x0327a93a __CFRunLoopRun + 1226
18 CoreFoundation 0x0327a1ab CFRunLoopRunSpecific + 443
19 CoreFoundation 0x03279fdb CFRunLoopRunInMode + 123
20 GraphicsServices 0x04aa924f GSEventRunModal + 192
21 GraphicsServices 0x04aa908c GSEventRun + 104
22 UIKit 0x00e36e16 UIApplicationMain + 1526
23 eAlth Devel 0x000f1c5c main + 76
24 libdyld.dylib 0x02a53ac9 start + 1
25 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
其錯誤之前調用的方法是:
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
NSObject * sel = [pickerData objectAtIndex:row];
return sel.description;
}
pickerData陣列對象不是零,它在它已下列對象:
self->pickerData:
<__NSArrayM 0x7c130080>(
All,
Br Clinic,
Clinic 2,
EssHth,
GC Clinic,
HHolistics,
K5003 - HHD3112,
K5003 - HHD3112 - Gp2,
NEW DEMO CLINIC,
Nursing Home Visits,
PR Accupuncture,
PP,
RB Therapy,
SC Clinic,
S Clinic,
TW Practice
)
關於如何解決該問題的任何建議? 在此先感謝!
您試圖索引的數組* *爲空。如果你在嘗試索引操作之前NSLog它,你會看到。 – 2014-09-29 01:15:43
很明顯,你沒有閱讀我寫的答案! 只有我在代碼中改變的東西在答案中提到! – chamalabey 2014-10-03 05:56:43
然後很明顯,當你跨過你所說的聲明時,問題不會發生。 – 2014-10-03 11:04:28