无法解决NULL cString崩溃问题

时间:2014-06-26 12:06:11

标签: ios iphone objective-c

您好我有以下代码崩溃应用程序:

cell.textLabel.text = [NSString stringWithCString:[[[self.arrayForTableSelLang objectAtIndex:indexPath.row] objectForKey:kSupport_question_title] cStringUsingEncoding:NSISOLatin1StringEncoding] encoding:NSUTF8StringEncoding];

错误是:

* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* +[NSString stringWithCString:encoding:]: NULL cString

NSLog给了我:

Wie lange dauert es, bis meine Guthaben-Ãœberweisung auf meiner Karte gebucht ist?

我该如何解决这个问题?

提前致谢。

1 个答案:

答案 0 :(得分:0)

我的意思是:

NSDictionary *langDict = self.arrayForTableSelLang[indexPath.row];
NSString *string = langDict[kSupport_question_title];
char *cString = [string cStringUsingEncoding:NSISOLatin1StringEncoding];
cell.textLabel.text = [NSString stringWithCString:cString encoding:NSUTF8StringEncoding];

<强>更新

以这种方式更新代码:

NSDictionary *langDict = self.arrayForTableSelLang[indexPath.row];
cell.textLabel.text = langDict[kSupport_question_title];