简体   繁体   English

如何知道要导入什么?

[英]How to know what to import?

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 例如,当我使用MFMailComposeViewController时,我通过谷歌搜索知道我需要

#import <MessageUI/MFMailComposeViewController.h>

and add: MessageUI.framework 并添加: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 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? 我想学习如何更好地使用参考文档而不依赖于谷歌搜索示例代码来找出我将来需要导入的内容,那么有人可以解释如何从文档中解决这个问题吗?

See how at the top it says it's declared in MFMailComposeViewController.h? 看看它在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. 从Xcode中的实际iOS项目开始。 Press Shift-Command-O (File > Open Quickly) and paste or type MFMailComposeViewController into it. 按Shift-Command-O(文件>快速打开)并粘贴或键入MFMailComposeViewController。 Open the listing for MFMailComposeViewController.h. 打开MFMailComposeViewController.h的列表。

Now read the jump bar at the top of the editor. 现在阅读编辑器顶部的跳转栏。 It says: ... > Frameworks > MessageUI.framework > ... 它说:...>框架> 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> . 这使您可以推断出您需要MessageUI框架并且需要导入(不是您所说的,但是) <MessageUI/MessageUI.h>

This is how I do it and it might be useful to you too.. 这就是我这样做的方式,也可能对你有用..

管理器截图

Have you notice the navigation bar on the top? 你注意到顶部的导航栏了吗? if you click "MFMailComposeViewController class Reference" field then it will give you something like this.. 如果你单击“MFMailComposeViewController类参考”字段,它会给你这样的东西..

在此输入图像描述

then you can see the "Message UI Framework Reference" and this page tells you exactly what you need to import.. this is not perfect but it helps most of time... 那么你可以看到“消息UI框架参考”,这个页面告诉你你需要导入什么...这不是完美的,但它有助于大部分时间......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM