在Uipickerview上设置Selectrow()时,超出了异常
我有一个Uipicker视图,并加载了INT数组作为其数据源。选择一行正常工作,但是当应用程序加载时,我想让它显示从磁盘读取的特定项目。
现在,我只是试图将特定的行号作为RAW INT传递,但在加载其抛出范围错误时。我的猜测是,它正在尝试在加载数据源之前选择该行,但我不确定如何解决此问题。
我的主要课程看起来像这样:
class ViewController: UIViewController {
let durations = Array(15...40)
override func viewDidLoad() {
super.viewDidLoad()
durationPickerOut.dataSource = self
durationPickerOut.delegate = self
durationPickerOut.selectRow(1, inComponent: 1, animated: false) // This is throwing the error
}
// MARK extensions
extension ViewController: UIPickerViewDataSource{
func numberOfComponents(in pickerView: UIPickerView) -> Int {
return 1
}
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
return durations.count
}
}
extension ViewController: UIPickerViewDelegate{
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
String(durations[row])
}
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
cycleDuration = durations[row]
}
}
一旦我可以选择一个任意的硬编码行,然后我将其切换到动态的东西,但是现在我只想将其设置为选择给定的行。 错误的错误是:
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
*** First throw call stack:
(
0 CoreFoundation 0x00000001803f3d70 __exceptionPreprocess + 236
1 libobjc.A.dylib 0x000000018019814c objc_exception_throw + 56
2 CoreFoundation 0x00000001804793b4 -[__NSCFString characterAtIndex:].cold.1 + 0
3 CoreFoundation 0x00000001802ebf38 -[__NSArrayM getObjects:range:] + 0
4 UIKitCore 0x0000000184d1e384 -[UIPickerView _selectRow:inComponent:animated:notify:] + 120
5 MyApp 0x000000010263aff8 $s015MyApp_Privacy_A014ViewControllerC11viewDidLoadyyF + 2496
6 MyApp 0x000000010263b7a4 $s015MyApp_Privacy_A014ViewControllerC11viewDidLoadyyFTo + 36
7 UIKitCore 0x00000001846342ec -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] + 104
8 UIKitCore 0x0000000184638898 -[UIViewController loadViewIfRequired] + 1020
9 UIKitCore 0x0000000184638c64 -[UIViewController view] + 28
10 UIKitCore 0x0000000184dca34c -[UIWindow addRootViewControllerViewIfPossible] + 176
11 UIKitCore 0x0000000184dc9b7c -[UIWindow _updateLayerOrderingAndSetLayerHidden:actionBlock:] + 224
12 UIKitCore 0x0000000184dca9a4 -[UIWindow _setHidden:forced:] + 252
13 UIKitCore 0x0000000184ddb3b4 -[UIWindow _mainQueue_makeKeyAndVisible] + 52
14 UIKitCore 0x0000000185021a20 -[UIWindowScene _makeKeyAndVisibleIfNeeded] + 200
15 UIKitCore 0x00000001841cc594 +[UIScene _sceneForFBSScene:create:withSession:connectionOptions:] + 1428
16 UIKitCore 0x0000000184d8a408 -[UIApplication _connectUISceneFromFBSScene:transitionContext:] + 1268
17 UIKitCore 0x0000000184d8a8b0 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 312
18 UIKitCore 0x000000018485dbb4 -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 360
19 FrontBoardServices 0x0000000186166718 -[FBSScene _callOutQueue_agent_didCreateWithTransitionContext:completion:] + 412
20 FrontBoardServices 0x0000000186192620 __94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke.180 + 100
21 FrontBoardServices 0x0000000186174d00 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 232
22 FrontBoardServices 0x000000018619223c __94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke + 312
23 libdispatch.dylib 0x00000001029f9b94 _dispatch_client_callout + 16
24 libdispatch.dylib 0x00000001029fce88 _dispatch_block_invoke_direct + 256
25 FrontBoardServices 0x00000001861b8074 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 40
26 FrontBoardServices 0x00000001861b7f4c -[FBSSerialQueue _targetQueue_performNextIfPossible] + 176
27 FrontBoardServices 0x00000001861b80a4 -[FBSSerialQueue _performNextFromRunLoopSource] + 24
28 CoreFoundation 0x0000000180362234 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
29 CoreFoundation 0x0000000180362134 __CFRunLoopDoSource0 + 204
30 CoreFoundation 0x0000000180361520 __CFRunLoopDoSources0 + 348
31 CoreFoundation 0x000000018035ba18 __CFRunLoopRun + 744
32 CoreFoundation 0x000000018035b218 CFRunLoopRunSpecific + 572
33 GraphicsServices 0x000000018c25f60c GSEventRunModal + 160
34 UIKitCore 0x0000000184d88a98 -[UIApplication _run] + 992
35 UIKitCore 0x0000000184d8d634 UIApplicationMain + 112
36 libswiftUIKit.dylib 0x00000001b6946224 $s5UIKit17UIApplicationMainys5Int32VAD_SpySpys4Int8VGGSgSSSgAJtF + 100
37 MyApp 0x000000010263fa04 $sSo21UIApplicationDelegateP5UIKitE4mainyyFZ + 104
38 MyApp 0x000000010263f98c $s015MyApp_Privacy_A011AppDelegateC5$mainyyFZ + 44
39 MyApp 0x000000010263fa88 main + 28
40 dyld 0x0000000102975cd8 start_sim + 20
41 ??? 0x00000001027bd0f4 0x0 + 4336636148
42 ??? 0x464b800000000000 0x0 + 5065282943396610048
)
libc++abi: terminating with uncaught exception of type NSException
dyld4 config: DYLD_ROOT_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot DYLD_LIBRARY_PATH=/Users/squidgylabs/Library/Developer/Xcode/DerivedData/MyApp_Privacy_MyApp-cnetykaxqecqzpatuvwawzyuqfwr/Build/Products/Debug-iphonesimulator:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libBacktraceRecording.dylib:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libMainThreadChecker.dylib:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib DYLD_FRAMEWORK_PATH=/Users/squidgylabs/Library/Developer/Xcode/DerivedData/MyApp_Privacy_MyApp-cnetykaxqecqzpatuvwawzyuqfwr/Build/Products/Debug-iphonesimulator
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
terminating with uncaught exception of type NSException
CoreSimulator 802.6.1 - Device: iPhone 13 Pro (EC065371-1DB1-48A9-A629-365188E36AAE) - Runtime: iOS 15.5 (19F70) - DeviceType: iPhone 13 Pro
(lldb) *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
*** First throw call stack:
(
0 CoreFoundation 0x00000001803f3d70 __exceptionPreprocess + 236
1 libobjc.A.dylib 0x000000018019814c objc_exception_throw + 56
2 CoreFoundation 0x00000001804793b4 -[__NSCFString characterAtIndex:].cold.1 + 0
3 CoreFoundation 0x00000001802ebf38 -[__NSArrayM getObjects:range:] + 0
4 UIKitCore 0x0000000184d1e384 -[UIPickerView _selectRow:inComponent:animated:notify:] + 120
5 MyApp 0x000000010263aff8 $s015MyApp_Privacy_A014ViewControllerC11viewDidLoadyyF + 2496
6 MyApp 0x000000010263b7a4 $s015MyApp_Privacy_A014ViewControllerC11viewDidLoadyyFTo + 36
7 UIKitCore 0x00000001846342ec -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] + 104
8 UIKitCore 0x0000000184638898 -[UIViewController loadViewIfRequired] + 1020
9 UIKitCore 0x0000000184638c64 -[UIViewController view] + 28
10 UIKitCore 0x0000000184dca34c -[UIWindow addRootViewControllerViewIfPossible] + 176
11 UIKitCore 0x0000000184dc9b7c -[UIWindow _updateLayerOrderingAndSetLayerHidden:actionBlock:] + 224
12 UIKitCore 0x0000000184dca9a4 -[UIWindow _setHidden:forced:] + 252
13 UIKitCore 0x0000000184ddb3b4 -[UIWindow _mainQueue_makeKeyAndVisible] + 52
14 UIKitCore 0x0000000185021a20 -[UIWindowScene _makeKeyAndVisibleIfNeeded] + 200
15 UIKitCore 0x00000001841cc594 +[UIScene _sceneForFBSScene:create:withSession:connectionOptions:] + 1428
16 UIKitCore 0x0000000184d8a408 -[UIApplication _connectUISceneFromFBSScene:transitionContext:] + 1268
17 UIKitCore 0x0000000184d8a8b0 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 312
18 UIKitCore 0x000000018485dbb4 -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 360
19 FrontBoardServices 0x0000000186166718 -[FBSScene _callOutQueue_agent_didCreateWithTransitionContext:completion:] + 412
20 FrontBoardServices 0x0000000186192620 __94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke.180 + 100
21 FrontBoardServices 0x0000000186174d00 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 232
22 FrontBoardServices 0x000000018619223c __94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke + 312
23 libdispatch.dylib 0x00000001029f9b94 _dispatch_client_callout + 16
24 libdispatch.dylib 0x00000001029fce88 _dispatch_block_invoke_direct + 256
25 FrontBoardServices 0x00000001861b8074 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 40
26 FrontBoardServices 0x00000001861b7f4c -[FBSSerialQueue _targetQueue_performNextIfPossible] + 176
27 FrontBoardServices 0x00000001861b80a4 -[FBSSerialQueue _performNextFromRunLoopSource] + 24
28 CoreFoundation 0x0000000180362234 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
29 CoreFoundation 0x0000000180362134 __CFRunLoopDoSource0 + 204
30 CoreFoundation 0x0000000180361520 __CFRunLoopDoSources0 + 348
31 CoreFoundation 0x000000018035ba18 __CFRunLoopRun + 744
32 CoreFoundation 0x000000018035b218 CFRunLoopRunSpecific + 572
33 GraphicsServices 0x000000018c25f60c GSEventRunModal + 160
34 UIKitCore 0x0000000184d88a98 -[UIApplication _run] + 992
35 UIKitCore 0x0000000184d8d634 UIApplicationMain + 112
36 libswiftUIKit.dylib 0x00000001b6946224 $s5UIKit17UIApplicationMainys5Int32VAD_SpySpys4Int8VGGSgSSSgAJtF + 100
37 MyApp 0x000000010263fa04 $sSo21UIApplicationDelegateP5UIKitE4mainyyFZ + 104
38 MyApp 0x000000010263f98c $s015MyApp_Privacy_A011AppDelegateC5$mainyyFZ + 44
39 MyApp 0x000000010263fa88 main + 28
40 dyld 0x0000000102975cd8 start_sim + 20
41 ??? 0x00000001027bd0f4 0x0 + 4336636148
42 ??? 0x464b800000000000 0x0 + 5065282943396610048
)
libc++abi: terminating with uncaught exception of type NSException
dyld4 config: DYLD_ROOT_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot DYLD_LIBRARY_PATH=/Users/squidgylabs/Library/Developer/Xcode/DerivedData/MyApp_Privacy_MyApp-cnetykaxqecqzpatuvwawzyuqfwr/Build/Products/Debug-iphonesimulator:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libBacktraceRecording.dylib:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libMainThreadChecker.dylib:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib DYLD_FRAMEWORK_PATH=/Users/squidgylabs/Library/Developer/Xcode/DerivedData/MyApp_Privacy_MyApp-cnetykaxqecqzpatuvwawzyuqfwr/Build/Products/Debug-iphonesimulator
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
terminating with uncaught exception of type NSException
CoreSimulator 802.6.1 - Device: iPhone 13 Pro (EC065371-1DB1-48A9-A629-365188E36AAE) - Runtime: iOS 15.5 (19F70) - DeviceType: iPhone 13 Pro
(lldb) MyApp
I have a UIPicker view and which loads an array of Ints as its data source. Selecting a row works fine, however when the app loads I want to have it display a specific item that is read from disk.
Right now I'm just trying to pass in a specific row number as a raw int but at load its throwing an out of bounds error. My guess is that it's trying to select the row before it has loaded its data source but I'm not sure how to fix this.
My main class looks like this:
class ViewController: UIViewController {
let durations = Array(15...40)
override func viewDidLoad() {
super.viewDidLoad()
durationPickerOut.dataSource = self
durationPickerOut.delegate = self
durationPickerOut.selectRow(1, inComponent: 1, animated: false) // This is throwing the error
}
// MARK extensions
extension ViewController: UIPickerViewDataSource{
func numberOfComponents(in pickerView: UIPickerView) -> Int {
return 1
}
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
return durations.count
}
}
extension ViewController: UIPickerViewDelegate{
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
String(durations[row])
}
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
cycleDuration = durations[row]
}
}
Once I can select an arbitrary hard coded row then I'll switch it to something dynamic but right now I just want to be able to set it to select a given row.
The error thrown is this:
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
*** First throw call stack:
(
0 CoreFoundation 0x00000001803f3d70 __exceptionPreprocess + 236
1 libobjc.A.dylib 0x000000018019814c objc_exception_throw + 56
2 CoreFoundation 0x00000001804793b4 -[__NSCFString characterAtIndex:].cold.1 + 0
3 CoreFoundation 0x00000001802ebf38 -[__NSArrayM getObjects:range:] + 0
4 UIKitCore 0x0000000184d1e384 -[UIPickerView _selectRow:inComponent:animated:notify:] + 120
5 MyApp 0x000000010263aff8 $s015MyApp_Privacy_A014ViewControllerC11viewDidLoadyyF + 2496
6 MyApp 0x000000010263b7a4 $s015MyApp_Privacy_A014ViewControllerC11viewDidLoadyyFTo + 36
7 UIKitCore 0x00000001846342ec -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] + 104
8 UIKitCore 0x0000000184638898 -[UIViewController loadViewIfRequired] + 1020
9 UIKitCore 0x0000000184638c64 -[UIViewController view] + 28
10 UIKitCore 0x0000000184dca34c -[UIWindow addRootViewControllerViewIfPossible] + 176
11 UIKitCore 0x0000000184dc9b7c -[UIWindow _updateLayerOrderingAndSetLayerHidden:actionBlock:] + 224
12 UIKitCore 0x0000000184dca9a4 -[UIWindow _setHidden:forced:] + 252
13 UIKitCore 0x0000000184ddb3b4 -[UIWindow _mainQueue_makeKeyAndVisible] + 52
14 UIKitCore 0x0000000185021a20 -[UIWindowScene _makeKeyAndVisibleIfNeeded] + 200
15 UIKitCore 0x00000001841cc594 +[UIScene _sceneForFBSScene:create:withSession:connectionOptions:] + 1428
16 UIKitCore 0x0000000184d8a408 -[UIApplication _connectUISceneFromFBSScene:transitionContext:] + 1268
17 UIKitCore 0x0000000184d8a8b0 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 312
18 UIKitCore 0x000000018485dbb4 -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 360
19 FrontBoardServices 0x0000000186166718 -[FBSScene _callOutQueue_agent_didCreateWithTransitionContext:completion:] + 412
20 FrontBoardServices 0x0000000186192620 __94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke.180 + 100
21 FrontBoardServices 0x0000000186174d00 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 232
22 FrontBoardServices 0x000000018619223c __94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke + 312
23 libdispatch.dylib 0x00000001029f9b94 _dispatch_client_callout + 16
24 libdispatch.dylib 0x00000001029fce88 _dispatch_block_invoke_direct + 256
25 FrontBoardServices 0x00000001861b8074 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 40
26 FrontBoardServices 0x00000001861b7f4c -[FBSSerialQueue _targetQueue_performNextIfPossible] + 176
27 FrontBoardServices 0x00000001861b80a4 -[FBSSerialQueue _performNextFromRunLoopSource] + 24
28 CoreFoundation 0x0000000180362234 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
29 CoreFoundation 0x0000000180362134 __CFRunLoopDoSource0 + 204
30 CoreFoundation 0x0000000180361520 __CFRunLoopDoSources0 + 348
31 CoreFoundation 0x000000018035ba18 __CFRunLoopRun + 744
32 CoreFoundation 0x000000018035b218 CFRunLoopRunSpecific + 572
33 GraphicsServices 0x000000018c25f60c GSEventRunModal + 160
34 UIKitCore 0x0000000184d88a98 -[UIApplication _run] + 992
35 UIKitCore 0x0000000184d8d634 UIApplicationMain + 112
36 libswiftUIKit.dylib 0x00000001b6946224 $s5UIKit17UIApplicationMainys5Int32VAD_SpySpys4Int8VGGSgSSSgAJtF + 100
37 MyApp 0x000000010263fa04 $sSo21UIApplicationDelegateP5UIKitE4mainyyFZ + 104
38 MyApp 0x000000010263f98c $s015MyApp_Privacy_A011AppDelegateC5$mainyyFZ + 44
39 MyApp 0x000000010263fa88 main + 28
40 dyld 0x0000000102975cd8 start_sim + 20
41 ??? 0x00000001027bd0f4 0x0 + 4336636148
42 ??? 0x464b800000000000 0x0 + 5065282943396610048
)
libc++abi: terminating with uncaught exception of type NSException
dyld4 config: DYLD_ROOT_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot DYLD_LIBRARY_PATH=/Users/squidgylabs/Library/Developer/Xcode/DerivedData/MyApp_Privacy_MyApp-cnetykaxqecqzpatuvwawzyuqfwr/Build/Products/Debug-iphonesimulator:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libBacktraceRecording.dylib:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libMainThreadChecker.dylib:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib DYLD_FRAMEWORK_PATH=/Users/squidgylabs/Library/Developer/Xcode/DerivedData/MyApp_Privacy_MyApp-cnetykaxqecqzpatuvwawzyuqfwr/Build/Products/Debug-iphonesimulator
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
terminating with uncaught exception of type NSException
CoreSimulator 802.6.1 - Device: iPhone 13 Pro (EC065371-1DB1-48A9-A629-365188E36AAE) - Runtime: iOS 15.5 (19F70) - DeviceType: iPhone 13 Pro
(lldb) *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
*** First throw call stack:
(
0 CoreFoundation 0x00000001803f3d70 __exceptionPreprocess + 236
1 libobjc.A.dylib 0x000000018019814c objc_exception_throw + 56
2 CoreFoundation 0x00000001804793b4 -[__NSCFString characterAtIndex:].cold.1 + 0
3 CoreFoundation 0x00000001802ebf38 -[__NSArrayM getObjects:range:] + 0
4 UIKitCore 0x0000000184d1e384 -[UIPickerView _selectRow:inComponent:animated:notify:] + 120
5 MyApp 0x000000010263aff8 $s015MyApp_Privacy_A014ViewControllerC11viewDidLoadyyF + 2496
6 MyApp 0x000000010263b7a4 $s015MyApp_Privacy_A014ViewControllerC11viewDidLoadyyFTo + 36
7 UIKitCore 0x00000001846342ec -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] + 104
8 UIKitCore 0x0000000184638898 -[UIViewController loadViewIfRequired] + 1020
9 UIKitCore 0x0000000184638c64 -[UIViewController view] + 28
10 UIKitCore 0x0000000184dca34c -[UIWindow addRootViewControllerViewIfPossible] + 176
11 UIKitCore 0x0000000184dc9b7c -[UIWindow _updateLayerOrderingAndSetLayerHidden:actionBlock:] + 224
12 UIKitCore 0x0000000184dca9a4 -[UIWindow _setHidden:forced:] + 252
13 UIKitCore 0x0000000184ddb3b4 -[UIWindow _mainQueue_makeKeyAndVisible] + 52
14 UIKitCore 0x0000000185021a20 -[UIWindowScene _makeKeyAndVisibleIfNeeded] + 200
15 UIKitCore 0x00000001841cc594 +[UIScene _sceneForFBSScene:create:withSession:connectionOptions:] + 1428
16 UIKitCore 0x0000000184d8a408 -[UIApplication _connectUISceneFromFBSScene:transitionContext:] + 1268
17 UIKitCore 0x0000000184d8a8b0 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 312
18 UIKitCore 0x000000018485dbb4 -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 360
19 FrontBoardServices 0x0000000186166718 -[FBSScene _callOutQueue_agent_didCreateWithTransitionContext:completion:] + 412
20 FrontBoardServices 0x0000000186192620 __94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke.180 + 100
21 FrontBoardServices 0x0000000186174d00 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 232
22 FrontBoardServices 0x000000018619223c __94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke + 312
23 libdispatch.dylib 0x00000001029f9b94 _dispatch_client_callout + 16
24 libdispatch.dylib 0x00000001029fce88 _dispatch_block_invoke_direct + 256
25 FrontBoardServices 0x00000001861b8074 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 40
26 FrontBoardServices 0x00000001861b7f4c -[FBSSerialQueue _targetQueue_performNextIfPossible] + 176
27 FrontBoardServices 0x00000001861b80a4 -[FBSSerialQueue _performNextFromRunLoopSource] + 24
28 CoreFoundation 0x0000000180362234 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
29 CoreFoundation 0x0000000180362134 __CFRunLoopDoSource0 + 204
30 CoreFoundation 0x0000000180361520 __CFRunLoopDoSources0 + 348
31 CoreFoundation 0x000000018035ba18 __CFRunLoopRun + 744
32 CoreFoundation 0x000000018035b218 CFRunLoopRunSpecific + 572
33 GraphicsServices 0x000000018c25f60c GSEventRunModal + 160
34 UIKitCore 0x0000000184d88a98 -[UIApplication _run] + 992
35 UIKitCore 0x0000000184d8d634 UIApplicationMain + 112
36 libswiftUIKit.dylib 0x00000001b6946224 $s5UIKit17UIApplicationMainys5Int32VAD_SpySpys4Int8VGGSgSSSgAJtF + 100
37 MyApp 0x000000010263fa04 $sSo21UIApplicationDelegateP5UIKitE4mainyyFZ + 104
38 MyApp 0x000000010263f98c $s015MyApp_Privacy_A011AppDelegateC5$mainyyFZ + 44
39 MyApp 0x000000010263fa88 main + 28
40 dyld 0x0000000102975cd8 start_sim + 20
41 ??? 0x00000001027bd0f4 0x0 + 4336636148
42 ??? 0x464b800000000000 0x0 + 5065282943396610048
)
libc++abi: terminating with uncaught exception of type NSException
dyld4 config: DYLD_ROOT_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot DYLD_LIBRARY_PATH=/Users/squidgylabs/Library/Developer/Xcode/DerivedData/MyApp_Privacy_MyApp-cnetykaxqecqzpatuvwawzyuqfwr/Build/Products/Debug-iphonesimulator:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libBacktraceRecording.dylib:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libMainThreadChecker.dylib:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib DYLD_FRAMEWORK_PATH=/Users/squidgylabs/Library/Developer/Xcode/DerivedData/MyApp_Privacy_MyApp-cnetykaxqecqzpatuvwawzyuqfwr/Build/Products/Debug-iphonesimulator
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
terminating with uncaught exception of type NSException
CoreSimulator 802.6.1 - Device: iPhone 13 Pro (EC065371-1DB1-48A9-A629-365188E36AAE) - Runtime: iOS 15.5 (19F70) - DeviceType: iPhone 13 Pro
(lldb) MyApp
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它与
uitaiteView
行为一样简单,而我们在提供uitableview
和uipickerview
的数据源时,我们使用int> int
定义各节数的值,排为uitaiteView
和列,行,uipickerview
。在您使用
Uipickerview
的情况下,您告诉您需要一列,这是主要重点,访问
组件
and行
它将一直启动来自0,1,2 ...(N-1)
,因此,现在您可以通过更改默认选择列为
0
来解决此问题,It is as simple as
UITableView
behaviour, while we are supplying the data source for bothUITableView
andUIPickerView
we useInt
value which defines the number of sections, rows to theUITableView
and Columns, row to theUIPickerView
.In your case working with
UIPickerView
, you told one column is requiredHere is the main focus, while accessing the
component
androw
it will alway starts from0,1,2...(N-1)
So, now you can fix this by changing the default selecting column to
0
as you are supplying one column它基于零,这意味着行以0至&lt开头; n(n是行的数量)对于组件相同
It's zero based , meaning row starts with 0 to < N (N is the number of rows) same for component