my xcode 4 just crashed and I get build errors:
Unknown type name
‘SecondViewController’
in the @interface code block:
SecondViewController *sms;
and
Property with ‘retain’ attribute must
be object type
in
@property(nonatomic,retain) SecondViewController *sms;
However I import SecondViewController.h. The same code worked before the crash.
FirstViewController.h: http://pastebin.com/jnPKBny7
SecondViewController.h: http://pastebin.com/2D058ZAK
Edit: I realized that this error occures because the classes import each other. Can anyone describe why this is wrong?
Any ideas?
You can’t have circular imports. I think it’s good practice to use forward class declarations with the @class directive whenever possible. For your case:
FirstViewController.h:
SecondViewController.h:
Then in your .m files, import the .h files for the classes you are using. The only reasons to import .h files into other .h files are: