Question

It is said that when a UIView object is created with programmer's code, then initWithFrame is the method to use for initialization, but when the UIView object is created with a NIB, then initWithCoder is used for initialization.

When a new subclass of UIView is created within Xcode, is there a way to make it so that the proper initWithCoder is created, because right now the usual method that is created is initWithFrame and I wonder if there is some steps in Xcode that I did wrong so it created initWithFrame instead -- could I have made it create initWithCoder instead?

Was it helpful?

Solution

You could tweak your Xcode template file (for UIView subclasses) and put the initWithCoder method in - so that you won't have to rewrite it every single time.

If you want to know how to edit those template files, have a look at my answer here :

How to change entire copyright notice template for Xcode?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top