Error with setBorderStyle and setPlaceHolder


#1

I am following your code on page 185 and received an error for the last two lines of code for setBorderStyle and setPlaceholder. Xcode generated this message, "! Receiver type ‘UITextView’ for instance message does not declare a method with selector 'setBorderStyle’
I am not sure what this means.

// Create and configure the text field where new tasks will be entered
taskField = [[UITextField alloc] initWithFrame:fieldFrame];
[taskField setBorderStyle:UITextBorderStyleRoundedRect];
[taskField setPlaceholder:@“Type a task, tap Insert”];


#2

Which book? (Because you are posting in General Discussions)

By the way, you can use the code tags to make your code stand out from the rest of the crowd like this:

static const char *stations [] = {"ABC AM 729", "ABC AM 891", "ABC AM 972", "ABC FM Triple J"};
static const NSUInteger NUMBER_OF_STATIONS = sizeof (stations) / sizeof (stations [0]);

#3

I am using your Objective C Programming, Big Nerd Ranch Guide. Sorry, I am new to your site. Please let me know if I should be posting my questions differently. Thanks.


#4

You can post to book’s own forum: http://forums.bignerdranch.com/viewforum.php?f=131

As for the errors:

[quote]Receiver type ‘[color=#FF0000]UITextView[/color]’ for instance message does not declare a method with selector 'setBorderStyle’
I am not sure what this means.[/quote]

// Create and configure the text field where new tasks will be entered
taskField = [[UITextField alloc] initWithFrame:fieldFrame];
[taskField setBorderStyle:UITextBorderStyleRoundedRect];
[taskField setPlaceholder:@"Type a task, tap Insert"];

What is the type of taskField? The error is referring to UITextView but you are setting taskField to an instance of UITextField.

Also, What version of Xcode are you using?


#5

Thank you! You were right on target about the field type. I made an error in the header field when I declared the taskField as UITextView type when it should be “UITextField.” I am using Xcode 4.2.1. Thank you again!