IOS miscellaneous-14 (forgotten owner), ios-14
* The owner has rarely used any children's shoes during development. You can check them out *
We often encounter a similar
[[NSBundle mainBundle] loadNibNamed: @ "Food" owner: nil options: nil] lastObject.
The general practice is to directly set the owner to self (usually when the cell is customized ).
But when defining other controls, we need to think about why, or what else needs attention.
Next I will introduce the owner.
Observe the following gif content carefully:
It is not difficult to find that the space I am trying to drag is unsuccessful. Why ???
Next, let's take a look at the gif below.
We drag the control successfully (note * here is why the number of owenr applications is getting fewer and fewer, because of the high coupling row sets, which is not suitable for improving the encoding efficiency)
Simple application:
//// ViewController. m // the owner that CX has forgotten // Created by ma c on 16/3/26. // Copyright©2016 xubaoaichiyu. all rights reserved. // # import "ViewController. h "@ interface ViewController () @ property (weak, nonatomic) IBOutlet UIButton * foodOne; @ property (weak, nonatomic) IBOutlet UIButton * foodTwo; @ end @ implementation ViewController-(IBAction) foodOneAction :( id) sender {NSLog (@ "foodOne");}-(IBAction) foodTwoAction :( id) sender {NSLog (@ "foodTwo");}-(void) viewDidLoad {[super viewDidLoad]; self. view = [[[NSBundle mainBundle] loadNibNamed: @ "Food" owner: self options: nil] lastObject];} @ end