Question

Take a look for example this:

SLServiceTypeTwitter

It's declared somewhere

The documentation says it's declared in SLRequest.h SLServiceTypes.h

So what exactly should I include?

Should I do

#import <SLRequest.h>

What?

SLRequest.h is most likely part of a framework. What framework? How do I know?

I often find this problem. Often I make a good guess. Ah I do

#import <Accounts/Accounts.h>

But that's not it. It doesn't work.

What should I include?

Is there a systematic way to find what exactly I should include?

This is for xcode

Note: with educated guess I found that I should do

#import <Social/Social.h>

But how the hell I was supposed to know that? I suppose I can find SLRequest.h and see it's part of Social framework and realize that I should include a .h file with the same name of the framework.

Another way to guess is to see that SL sounds a lot like social.

I wonder if my method is the official way to know.

Was it helpful?

Solution

Looking up SLServiceTypeTwitter in the documentation will lead you to the SLRequest Class Reference, which at the very top shows that it is part of the "Social.framework".

And from "Including Frameworks in Your Project" in the "Framework Programming Guide" (emphasis mine):

When including framework header files, it is traditional to include only the master framework header file. The master header file is the header file whose name matches the name of the framework. For example, the Address Book framework has a master header file with the name AddressBook.h. To include this header in your source, you would use the following directive:

#import <AddressBook/AddressBook.h>

In your case, the "official" import for the Social framework is

#import <Social/Social.h>

OTHER TIPS

It's all in the documentation. When you type SLServiceTypeTwitter in xcode, you can look up the method/property on in class reference by Option+left click. At the top of the reference lists which class it belongs to, and it tells you which framework it is part of, Social.framework in this case. So you know Social.h is part of Social framework and it should be declared like this: #import

SLRequest Class Reference

Inherits from
NSObject Conforms to NSObject (NSObject) Framework
/System/Library/Frameworks/Social.framework Availability
Available in iOS 6.0 and later. Declared in SLRequest.h SLServiceTypes.h

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