In a custom xib file, what's the difference between the two following setting methods shown in the images below?
Asked
Active
Viewed 1.1k times
58
2 Answers
7
please check this link : What is the File's Owner (in Interface builder)? confused difference between Custom Class for an Object and for the File's Owner and steps via IB
in first screen shot : you should set the custom class of your View .
and in the second screen shot (files owner
) you can Set the file's owner to your UIView subclass so that you can connect outlets to it

Community
- 1
- 1

Mo Farhand
- 1,144
- 8
- 21
-
Thank you, I got it from your answer! – Alfy Jan 20 '16 at 09:00
-
11I still cannot figure it out from your explanation, I have a subclass of `UITableViewCell` with certain customization functions, however I've tested that no matter where I assign this subclass, as File's Owner or Custom Class, there is no difference at all, I cannot set and connect outlets regardless the places. Even I set to both places it still behaved the exactly the same. – Saorikido Mar 03 '17 at 13:52
-
@Mazen WDM that you can't find a difference ? – Mo Farhand Apr 15 '17 at 23:49
-
6It works even if I set the class to the UIView, not the file owner. I can connect an outlet to a UILabel and edit its contents. I can't find any difference between setting the class to the file's owner vs to the view. – Mazen Apr 16 '17 at 08:32
0
When you add custom UIView
with XIB
you init this custom view in some UIViewController
and write:
let nib = UINib(nibName: "CardView", bundle: nil)
let view = nib.instantiate(withOwner: self, options: nil).first as! CardView
File's owner (in withOwner:
parameter) this is usually owner is a ViewController where you add your custom
UIView

Janserik
- 2,306
- 1
- 24
- 43