Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know what to import?

Tags:

ios

I have always been confused in finding out what i need to import in order to use a feature.

For example, when i use MFMailComposeViewController I know from googling that i need to

#import <MessageUI/MFMailComposeViewController.h>

and add: MessageUI.framework

From the reference documentation, how do I know that i need these things?

http://developer.apple.com/library/ios/#documentation/MessageUI/Reference/MFMailComposeViewController_class/Reference/Reference.html

I want to learn how to better use the reference docs without relying on googling sample codes to find out what i need to import in the future, so can someone explain how to figure this out from documentation?

like image 955
Jim Avatar asked Oct 22 '22 12:10

Jim


1 Answers

See how at the top it says it's declared in MFMailComposeViewController.h? The question then is what framework that's in. Here's one way to find out.

Start in an actual iOS project in Xcode. Press Shift-Command-O (File > Open Quickly) and paste or type MFMailComposeViewController into it. Open the listing for MFMailComposeViewController.h.

Now read the jump bar at the top of the editor. It says: ... > Frameworks > MessageUI.framework > ...

This lets you deduce that you need the MessageUI framework and that you need to import (not what you said, but) <MessageUI/MessageUI.h>.

like image 148
matt Avatar answered Nov 01 '22 12:11

matt