views:

110

answers:

2

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.

A: 

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.

Martin Gordon
+2  A: 

I use ClassNameView since the xib represents the view, not the view controller. I don't think there is a generally accepted convention.

henning77
I did not seem to find a generally accepted convention either. However, I read this blog post at http://www.cimgf.com/2009/05/11/magical-iphone-view-controllers/ that says when using init (not initWithNibName), it assumes the nib is named ClassNameView.I'll probably go with View because like you said henning, it's not the view controller.
baalexander