objective-c,uitableview,xib,custom-cell,awakefromnib
awakeFromNib is an initializer called when you load from nib..ie you add a view and change its class to your custom class in storyboard/nib and this porcess will call awakeFromNib method..not programatically When done programatically use init method for the purpose or a custom initializer -(id)init { //class super init...
objective-c,uitableview,xib,custom-cell,awakefromnib
awakeFromNib is called when all file owners outlets and properties are set. Things are not wired up (in terms of frames/layout) in viewDidLoad. awakeFromNib is called after viewDidLoad, that is why you see the difference....
ios,uitableview,swift,uiview,awakefromnib
If you want to use a var as soon as you have it, you can use it's didSet observer like so: class ListUsersView: UIView { @IBOutlet var tableView: UITableView! { didSet{ tableView.registerNib(UINib(nibName: nameForCellNib!, bundle:NSBundle.mainBundle()), forCellReuseIdentifier: nameForCellNib!) } } . . . } ...
ios,objective-c,datasource,awakefromnib
If you put a breakpoint in -awakeFromNib method, you'll see that this method executes as it should. The thing is, that this method called before datasource assignment, and at this moment your self.datasource is nil. I suggest you to override the setter of the datasource property and initialize your data...
ios,objective-c,xib,awakefromnib
I have had the worst luck loading nibs and issues searching for an easy way to do so. This is what worked for me in the past. Add this to customCell.m - (id)initWithNib { // where MyCustomView is the name of your nib UINib *nib = [UINib nibWithNibName:@"customCell" bundle:[NSBundle mainBundle]];...