1

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?

nonopolarity
  • 146,324
  • 131
  • 460
  • 740

1 Answers1

2

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?

Community
  • 1
  • 1
Dr.Kameleon
  • 22,532
  • 20
  • 115
  • 223