Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error after connecting IBOutlet to UITextField

I'm getting this weird error when I connect an IBOutlet to a UITextField. It's really weird because it's only happening in this one view controller. I have two other view controllers almost identical to this one, and they function perfectly. I have a table view controller in my storyboard. It has 2 grouped sections, each with static cells. Each cell has a UITextField in it. Now, the view loads fine if I just run it without connecting the textfields to my class. However, when I do connect them, as soon as the view loads-the app crashes with this error, one for each textfield: [UITextField stringByTrimmingCharactersInSet:]: unrecognized selector sent to instance

Any idea what the cause of this could be? I'm very confused as I have other tableview controllers with the same contents and I've never gotten this error.

Here are some screenshots to help further explain my situation:

wiring diagram from Xcode

list of properties in a header file

Here is the code for my .m file:

    //
//  IdeaViewController.m
//  FinalJSApp
//
//  Created by Jacob Klapper on 10/20/13.
//
//

#import "IdeaViewController.h"

@interface IdeaViewController ()

@end

@implementation IdeaViewController

- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;

    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    }   
    else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
{
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

/*
#pragma mark - Navigation

// In a story board-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}

 */

@end
like image 361
Jacob Avatar asked Dec 07 '22 04:12

Jacob


1 Answers

You declare two properties, title and description, in your view controller that are already defined by UIViewControlller and NSObject respectively. Both of those properties as originally defined are NSStrings.

iOS is probably trying to access those properties, expecting an NSString, and getting one of your UITextFields.

Try renaming those properties and your problem should go away.

like image 141
Jonathan Arbogast Avatar answered Dec 26 '22 17:12

Jonathan Arbogast