0

I use NSLog(@"%@");

And the NSLog result is '23204239423' I don't explain you why ... it's just an example.

I want the NSLog result appear in UILabel, is it possible ?

I tried : Label.text = (@"%@"); , it doesn't work.

Do you know how i can do it ?

Thanks.

user1659987
  • 85
  • 3
  • 5
  • I assume you mean you do something like `NSLog(@"%@",someObject);`. Doing `NSLog(@"%@"), will attempt to interpret whatever garbage follows the @"%@" string in storage as an object, and that's likely to fail -- or at best produce utter garbage. – Hot Licks Sep 10 '12 at 21:04

2 Answers2

8

NSLog usually takes a string like:

NSLog(@"%@", string);

So instead just do this:

label.text = [NSString stringWithFormat:@"%@", string];
firestream
  • 400
  • 2
  • 9
  • Yep, under the covers NSLog is using `stringWithFormat`. – Hot Licks Sep 10 '12 at 21:02
  • But, of course, if all that's being done is to assign `string` to the label text (nothing else added), that can be done directly, without any hocus-pocus. – Hot Licks Sep 10 '12 at 21:06
1

You have to put a variable

NSString *text = @"My Text";
label.text = text;

Or

label.text = @"Your text";
Jack
  • 10,943
  • 13
  • 50
  • 65