Reputation: 559
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]];
Upvotes: 0
Views: 2041
Reputation: 50697
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]
Upvotes: 0
Reputation: 10182
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:
.
Upvotes: 5
Reputation: 27506
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;
Upvotes: 1