Understanding iOS Compiler Errors – Interface type cannot be statically allocated

Interface type cannot be statically allocated

You usually get this error when you forget to include an
asterisk before a variable name this is an object pointer:

UILabel label = [[UILabel alloc] init];

To correct this problem, just add a asterisk before the
variable name:

UILabel *label =
[[UILabel alloc] init];

This is a common mistake for developers coming from other languages such as C# or Java.

For explanations of other compiler errors and warnings, check out our new book site: http://www.iOSAppsForEveryone.com

Kevin McNeish
Eight-time .NET MVP Recipient
Apple iOS Author, Trainer


Leave a Reply

Your email address will not be published. Required fields are marked *