0

I have been working on my application for a while now. I am stuck on this small problem: setting my text field's text isn't working.The string of the text field is called from another viewcontroller Here is what my code looks like:

1st view controller -(void)setURL:(NSURL *)src { downloadSourceField.text = src; } 2nd view controller

if ([[booksArray objectAtIndex:indexPath.row] isEqual:[NSString stringWithFormat:@"%@",song_1]]) 
{
    NSString *sc1 = [NSString stringWithFormat:@"tst 1"];
    [tc setURL:sc1];
}

else 
{
    NSString *sc = [NSString  stringWithFormat:@"test 2"];
    [tc setURL:sc];
}
8
  • 1
    If the text field is created in Interface Builder, double check the connection. Sending a message (setText: in this case) to a nil object will fail silently. Commented Apr 24, 2011 at 6:02
  • I have made the text field in the interface builder and have made sure it is all hooked up to it outlets and everything Commented Apr 24, 2011 at 6:58
  • Are you getting errors? If not, set a breakpoint on that line and check the variables. I would suspect that either downloadSourceField or src is nil (0x0). Commented Apr 24, 2011 at 7:24
  • downloadsourcefield is set to nil and that is what i am trying to change and set it to the text that is stored in src Commented Apr 24, 2011 at 7:29
  • okay now when i nslog the src it works fine but now when i try to put it in the uitextfield it changes to (null) for some reason Commented Apr 24, 2011 at 7:41

1 Answer 1

1

I think you're trying to assign an NSURL object to an NSString variable. What you should do is

downloadSourceField.text = [src absoluteString];

The absoluteString method will convert your NSURL into an NSString representation.

Sign up to request clarification or add additional context in comments.

1 Comment

please have a look at the comments above and look into the matter

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.