2014-12-18 31 views
0

我有一个iOS应用程序一直在两种语言工作得很好 - 我知道添加了一些东西,已经牢记使用NSLocalizedString进行本地化等英语版本的应用程序到目前为止工作得很好,但第二种语言版本在启动后立即崩溃。为什么?本地化的应用程序崩溃与NSRangeException

应该注意到我没有在我的localizable.strings文件中添加所有NSLocalizedStrings。此外,我有两个单独的故事板英文和德文。任何帮助将不胜感激!

2014-12-18 18:14:36.083 Coverdale[48297:60b] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 2 beyond bounds [0 .. 1]' 
*** First throw call stack: 
(
0 CoreFoundation      0x002461e4 __exceptionPreprocess + 180 
1 libobjc.A.dylib      0x020538e5 objc_exception_throw + 44 
2 CoreFoundation      0x001fa8b2 -[__NSArrayI objectAtIndex:] + 210 
3 UIKit        0x0126a35f -[UITableViewDataSource tableView:indentationLevelForRowAtIndexPath:] + 127 
4 UIKit        0x00fe3f34 -[UITableViewController tableView:indentationLevelForRowAtIndexPath:] + 61 
5 UIKit        0x00e012cf __53-[UITableView _configureCellForDisplay:forIndexPath:]_block_invoke + 1786 
6 UIKit        0x00d7581f +[UIView(Animation) performWithoutAnimation:] + 82 
7 UIKit        0x00d75868 +[UIView(Animation) _performWithoutAnimation:] + 40 
8 UIKit        0x00e00bd0 -[UITableView _configureCellForDisplay:forIndexPath:] + 108 
9 UIKit        0x00e0813d -[UITableView _createPreparedCellForGlobalRow:withIndexPath:] + 442 
10 UIKit        0x00e081f3 -[UITableView _createPreparedCellForGlobalRow:] + 69 
11 UIKit        0x00de9ece -[UITableView _updateVisibleCellsNow:] + 2428 
12 UIKit        0x00dfe6a5 -[UITableView layoutSubviews] + 213 
13 UIKit        0x00d7e964 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355 
14 libobjc.A.dylib      0x0206582b -[NSObject performSelector:withObject:] + 70 
15 QuartzCore       0x007c845a -[CALayer layoutSublayers] + 148 
16 QuartzCore       0x007bc244 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380 
17 QuartzCore       0x007bc0b0 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26 
18 QuartzCore       0x007227fa _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294 
19 QuartzCore       0x00723b85 _ZN2CA11Transaction6commitEv + 393 
20 QuartzCore       0x00724258 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92 
21 CoreFoundation      0x0020e36e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30 
22 CoreFoundation      0x0020e2bf __CFRunLoopDoObservers + 399 
23 CoreFoundation      0x001ec254 __CFRunLoopRun + 1076 
24 CoreFoundation      0x001eb9d3 CFRunLoopRunSpecific + 467 
25 CoreFoundation      0x001eb7eb CFRunLoopRunInMode + 123 
26 GraphicsServices     0x0406b5ee GSEventRunModal + 192 
27 GraphicsServices     0x0406b42b GSEventRun + 104 
28 UIKit        0x00d0ff9b UIApplicationMain + 1225 
29 Coverdale       0x0009b95d main + 141 
30 libdyld.dylib      0x028b9701 start + 1 
31 ???         0x00000001 0x0 + 1 
) 
libc++abi.dylib: terminating with uncaught exception of type NSException 
(lldb) 

编辑

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

static NSString *CellIdentifier = @"Cell"; 

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell == nil) { 
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; 
} 
cell.textLabel.text = @"Error"; 
if (indexPath.section == 0) { 
    if(indexPath.row == 0) 
    { /*..*/} 
} 
return cell; 
} 
+0

你可以添加代码块崩溃吗?如果你还没有缩小这个范围,设置一个异常断点来捕捉它的崩溃 – Chris

+0

嗨,谢谢你的回复。不幸的是,异常断点显示我只是main.m文件: INT主(INT ARGC,CHAR *的argv []){ @autoreleasepool { 回报UIApplicationMain(ARGC,ARGV,零,NSStringFromClass([MyAppDelegate类]) ); }} – Faser

+0

你可以发布你的表视图数据源方法吗?如果你实现'indentationLevelForRowAtIndexPath',发布它,否则发布你创建单元格的方法,因为它看起来像你的问题可能在那里。 – Chris

回答

2

原来我需要实现indentationLevelForRowAtIndexPath,只是return 0

相关问题