0

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]];
WrightsCS
  • 50,551
  • 22
  • 134
  • 186
aLFaRSi
  • 559
  • 2
  • 12
  • 29
  • 1
    Click the Plus button in the lower left corner and select "Add Exception Breakpoint..." – Costique Feb 21 '12 at 17:38
  • 2
    Add an exception breakpoint, enable breakpoints and post the line of code that the exception is being thrown on. Instructions for adding the breakpoint are here: http://stackoverflow.com/a/7736927/639668 – edc1591 Feb 21 '12 at 17:38

3 Answers3

5

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:.

edc1591
  • 10,146
  • 6
  • 40
  • 63
1

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;
sch
  • 27,436
  • 3
  • 68
  • 83
  • its not nil because there is some text in it, but now everything worked , thanks for helping :_) – aLFaRSi Feb 21 '12 at 17:58
0

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]

WrightsCS
  • 50,551
  • 22
  • 134
  • 186