I've been looking at the sample code and sometimes Apple names xib files ClassNameView
and sometimes ClassNameViewController
. The ClassName
is always a UIViewController
or UITableViewController
, which had me wonder what convention to use when naming a xib. I would think View as it's not really the ViewController
, but curious on what the convention is or at least what your naming conventions are for xibs.
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- Could I create “Call” button in HTML 5 IPhone appl
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Xcode: Is there a way to change line spacing (UI L
- Unable to process app at this time due to a genera
- Swift - hide pickerView after value selected
I use ClassNameView since the xib represents the view, not the view controller. I don't think there is a generally accepted convention.
CocoaTouch supports both conventions, with a preference for the shorter form ClassNameView, as per the nib loading process described below when a nib name is not specified (from the UIViewController documentation, under nibName):
So as other have said, it's a matter of preference! I personally like the shorter version but can see the logic in both.
I generally use ClassNameViewController since I set the File's Owner to that class and it seems strange to name the file after something that's a sub-object of the object the nib represents. Like you, I have seen it both ways in sample code and I did see a blog post about Cocoa explicitly looking for ClassNameView in some cases, but I haven't had any problems using ClassNameViewController.