Crystal
Crystal

Reputation: 29518

UITextView setText, getting null

I'm messing around with the iphone sdk and with universal apps. I have UITextView in both my iphone class and a shared class I called Shared (In my Shared class the UITextVIew is called textInput).

I have a UIButton that when pressed, calls a method of the Shared class since I allocate an instance of the Shared class when app finishes launching and gets the value from the UITextView in the Shared class and sets the UITextVIew to that text. I would think that would work, however in my IBAction method for the button being pressed, I've tried it two different ways of:

    [textInput setText:@"Accessing web service..."];
//  textInput.text = @"Accessing web service...";
    NSLog(@"self textInput: %s", [self textInput].text);

However, my NSLog shows null which I don't understand. But if I did something similar and in my UITextView of my iphone app delegate.m, if when the button is pressed, instead of calling the Shared method, I just said

textView.text = @"Hello"; // textView is the UITextVIew in my iphone class

it works. So I am having trouble seeing the disconnect. Any thoughts? Thanks.

Upvotes: 0

Views: 1029

Answers (1)

zpasternack
zpasternack

Reputation: 17898

Looks like it's just your NSLog call that's in error. NSLog uses %@ as an output specifier for NSStrings.

NSLog(@"self textInput: %@", textInput.text);

Upvotes: 1

Related Questions