Re: Unknown name type for an imported class in Xcode 6.x iOS 8 project
Re: Unknown name type for an imported class in Xcode 6.x iOS 8 project
- Subject: Re: Unknown name type for an imported class in Xcode 6.x iOS 8 project
- From: Alex Zavatone <email@hidden>
- Date: Thu, 30 Apr 2015 20:10:19 -0400
On Apr 30, 2015, at 5:57 PM, Quincey Morris wrote:
> On Apr 30, 2015, at 13:29 , William Squires <email@hidden> wrote:
>>
>> If I understand properly, you can't have a circular #import
>
> You can in the sense that if A.h #imports B.h, and B.h #imports A.h, then B.h can only see the contents of A.h up till the point that it #imports B.h. It’s circular (and therefore doesn’t produce the desired effect), though it’s not recursive like #include can be.
>
The view controllers import the appDelegate which has the SQLlite database ref in it. I'm changing the calls to the database to be async methods so I need a way to get back to the appDelegate's reference. No idea why it was done this way. It turns out that a few services are inited in the app startup methods of the appDelegate which ends up triggering the circular import later on. I may be able to escape this circular by moving them. Maybe.
> On Apr 30, 2015, at 13:07 , Alex Zavatone <email@hidden> wrote:
>
>> I'm including a .h file in my iOS app's AppDelegate.h. Say it's XXXX.h
>>
>> Right below the #import in the @interface, I've got an iVar of that class.
>>
>> And below the @interface, a property that's nonatomic and strong for an instance of that class.
>>
>> Xcode just started telling me that this class that I'm including is of "Unknown type name" on the lines where the iVar and the property are defined.
>
> It would be easier if you could just show a code fragment, because we have to guess what “below” means. Inside or outside braces? Before or after the @end?
>
> In any case, you’ll have an easier time of it if you don’t #import XXXX.h in situations like this. Instead, use a forward declaration of the class:
>
> @class XXXX;
>
> Also, don’t declare ivars in .h files. Put them in braces after @implemention in the .m file.
Ohhh, i know. But I've inherited a lovely project and there's only so many things I can fix at once.
I've got my work ahead of me, that's for sure.
> The cases where you must #import XXXX.h are restricted to these (or similar):
>
> — if XXX is a superclass of the class being declared
>
> — if XXXX.h contains non-class declarations (typedefs, enums, etc) that are *used* in the @interface section of AppDelegate.h.
>
Yeah, I've got my work cut out for me, that's for sure.
Thanks Quincey. I'm seeing new examples of ways to never ever code iOS apps. Who said learning isn't fun?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden