可能重复:
What is the best way to solve an Objective-C namespace collision?
在我的应用程序中,我使用SBJSON框架(Stig Brautaset)与我的json api进行交互,一切运行良好。
但是现在我正处于使用Facebook SDK使用Facebook SSO的情况。所以我按照Facebook developer site.
中的说明将facebook sdk包含在我的项目中但问题是,facebook sdk也使用了一些SBJSON类,比如SBJSONParser,SBJsonWriter等已经存在于我使用过的SBJSON框架中。这些类的名称相似,但方法和属性不同。所以我既不能删除也不能编辑其中任何一个。 (我是初学者,我不知道如何编辑它们而不会丢失任何东西)。
因为重复的类,它显示了许多错误。
我能在这做什么?请帮帮我:)
两个JSonParser类的头文件(.h)如下所示。 (.m文件不能在这里给出,因为它们太长了。)
在下面给出的Facebook SDK中使用的JSonParser.h
#import <Foundation/Foundation.h>
#import "SBJsonBase.h"
@protocol SBJsonParser
- (id)objectWithString:(NSString *)repr;
@end
@interface SBJsonParser : SBJsonBase <SBJsonParser> {
@private
const char *c;
}
@end
@interface SBJsonParser (Private)
- (id)fragmentWithString:(id)repr;
@end
在下面给出的SBJson Framework中使用的JSonParser.h
#import <Foundation/Foundation.h>
@interface SBJsonParser : NSObject {
NSString *error;
NSUInteger depth, maxDepth;
}
@property NSUInteger maxDepth;
@property(copy) NSString *error;
- (id)objectWithData:(NSData*)data;
- (id)objectWithData:(NSData*)data;
- (id)objectWithString:(NSString*)jsonText error:(NSError**)error;
@end
谢谢:)
答案 0 :(得分:0)
您需要确定要保留哪个SBJson实现,然后从项目设置中手动删除另一个。
主要问题是有很多好的iOS开源可用。但是,这种开源的分配方法充其量只是晦涩难懂。没有比在USB记忆棒上复制代码更高级或傻瓜了。
我写了一篇关于标题为 iOD开源状态:以及如何应对的主题的博客文章:http://blog.jayway.com/2011/05/16/the-state-of-ios-open-source-and-what-to-do-about-it/
我的建议是使用Xcode项目作为其他Xcode项目的依赖项的能力。效果很好,我用这种方法已经超过5年了,效果很好。
答案 1 :(得分:0)
试试这个:
JSonParser.h
)。 确保您之前拍摄快照,以便在出现问题时可以恢复。