Custom UITableViewCell with XIB

I looked around and there are many examples of how to do this, but I still do not understand.

I have a list in which I list the journal entries that I want to display the title, creation date, and several other things. I want to use XIB to create a cell, so the UX designer can modify it, and a pixel can click on it.

So this is how I install xib: enter image description here

Then I created the class this xib cell points to, and I added two properties to it:

@property (atomic, weak) IBOutlet UILabel* titleLabel; @property (atomic, weak) IBOutlet UILabel* dateLabel; 

I want to be able to set them when I create these cells.

In a view that has a list table, I do this: In - (void) viewDidLoad

 [self.tableView registerNib:[UINib nibWithNibName:@"DreamListTableViewCell" bundle:nil] forCellReuseIdentifier:@"DreamListCell"]; 

And in - (UITableViewCell *) tableView: (UITableView *) tableView cellForRowAtIndexPath: (NSIndexPath *) indexPath I do this:

 static NSString *MyIdentifier = @"DreamListCell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier forIndexPath:indexPath]; 

The problem is that the application crashes if I set IBOutlets in the xib cell, because I assume that the owner is really zero when it is initialized, but I'm not really sure. How can I change these two properties if I cannot connect them in the interface builder? What should I do differently?

In addition, I do not use storyboards. I use this as a guide: Chapter 21. Table Views and Collection Views

I apologize for one duplicate of the question, I just do not understand. Halp!

Edit: Screenshot: enter image description here

Edit # 2: If I delete the output connections in the xib cell, I see the following: enter image description here

+8
ios objective-c uitableview interface-builder
source share
1 answer

Do not use File Owner to establish relationships with IBOutlets. Change the cell class and use it instead (it can be difficult to make connections on some versions of Xcode, but doable).

+6
source share

All Articles