开发者

including a class from another folder in Xcode Objective-C

I have two folders under my project: WebServices and classes. How woul开发者_运维问答d I include DriverServiceService (in WebServices), in XMLViewController.h (in classes)?

I used the following with no luck:

#import <../WebServices/DriverServiceService>
#import <"WebServices/DriverServiceService">
#import <DriverServiceService>


try to import with without '<' and '>' and give the path as ../ if class is not in the root.

#import "../WebServices/DriverServiceService" worked for me.


If you want to use classes that are in a folder other than the root of your project, you can drag in or "add existing files" to your project. Make sure the "copy" option is unchecked. Now your project references those files in the project while they remain in their original location.


In some versions of Xcode, auto completion might not work.
Let's assume that the classes you are going to import are named "MyClass.h" and "MyClass.m"

To import, you simply give the filename like following:

#import "MyClass.h"


oops, nevermind

just learnt to use ""

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜