xCode 4.2 错误

发布于 2025-01-07 22:04:48 字数 1176 浏览 0 评论 0原文

当我尝试加载另一个视图时,出现此错误:

2012-02-21 20:31:38.477 App Demo[1671:f803] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSPlaceholderString initWithString:]: nil argument'

我找不到错误到底在哪里。

有什么帮助吗?

更新

NSString *pn1 = player1name.text;
NSString *pn2 = player2name.text;
NSString *pn3 = player3name.text;
NSString *pn4 = player4name.text;
NSString *k = kingdomLevel.text;

Kscores *kscores = [[Kscores alloc] initWithNibName:nil bundle:nil];
kscores.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:kscores animated:YES];


[[kscores player1name] setText:[NSString stringWithString:(NSString *)pn1]];
[[kscores player2name] setText:[NSString stringWithString:(NSString *)pn2]];
[[kscores player3name] setText:[NSString stringWithString:(NSString *)pn3]];
[[kscores player4name] setText:[NSString stringWithString:(NSString *)pn4]];
[[kscores king] setText:[NSString stringWithString:(NSString *)k]];

断点停在这段代码处

[[kscores player1name] setText:[NSString stringWithString:(NSString *)pn1]];

I'm getting this error when I try to load another view:

2012-02-21 20:31:38.477 App Demo[1671:f803] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSPlaceholderString initWithString:]: nil argument'

I couldn't find where is the error exactly.

Any help?

update

NSString *pn1 = player1name.text;
NSString *pn2 = player2name.text;
NSString *pn3 = player3name.text;
NSString *pn4 = player4name.text;
NSString *k = kingdomLevel.text;

Kscores *kscores = [[Kscores alloc] initWithNibName:nil bundle:nil];
kscores.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:kscores animated:YES];


[[kscores player1name] setText:[NSString stringWithString:(NSString *)pn1]];
[[kscores player2name] setText:[NSString stringWithString:(NSString *)pn2]];
[[kscores player3name] setText:[NSString stringWithString:(NSString *)pn3]];
[[kscores player4name] setText:[NSString stringWithString:(NSString *)pn4]];
[[kscores king] setText:[NSString stringWithString:(NSString *)k]];

breakpoint stopped at this code

[[kscores player1name] setText:[NSString stringWithString:(NSString *)pn1]];

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

失去的东西太少 2025-01-14 22:04:48

这样做 stringWithString: 有什么意义?您可以直接设置它,例如 [[kscores player1name] setText:pn1];

您收到错误是因为 pn1 为 nil,并且您无法将 nil 传递给stringWithString:

What's the point of doing stringWithString:? You can just set it directly like [[kscores player1name] setText:pn1];

You're getting the error because pn1 is nil, and you can't pass nil to stringWithString:.

丿*梦醉红颜 2025-01-14 22:04:48

这意味着该行中的 pn1nil

[[kscores player1name] setText:[NSString stringWithString:(NSString *)pn1]];

这意味着 player1nameplayer1name.text行中的 nil

NSString *pn1 = player1name.text;

That means that pn1 is nil in the line:

[[kscores player1name] setText:[NSString stringWithString:(NSString *)pn1]];

That means that player1name or player1name.text are nil in the line:

NSString *pn1 = player1name.text;
半衬遮猫 2025-01-14 22:04:48

您正在尝试传递 nil 参数:[[kscores player1name] setText:nil];[NSString stringWithString:(NSString *)pn1]NULL

相反,请尝试以下操作:[[kscores player1name] setText: pn1]

You are trying to pass a nil argument: [[kscores player1name] setText:nil]; since [NSString stringWithString:(NSString *)pn1] is NULL.

Instead, try this: [[kscores player1name] setText: pn1]

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文