ReactiveCocoa - 不适用于现有项目

时间:2015-04-23 15:23:24

标签: ios reactive-cocoa

我提到了How can I fix my install of ReactiveCocoa (with CocoaPods)?,但它没有帮助。基本上,如果我创建一个新项目并执行这些步骤:

1) sudo gem install cocoapods
2) pod init
3) Change Podfile to 

# platform :ios, ‘8.0’
target 'Test Project' do
pod 'ReactiveCocoa'
end
4) pod install

效果很好。

但是,当我尝试在下面的示例中对我当前的项目执行此操作时,它不起作用..

in .h

@property (strong, nonatomic) NSString *testString;

在viewDidLoad ..

self.testString = @"hello";
[RACObserve(self, testString) subscribeNext:^(NSString *newString) {
    NSLog(@"%@", newString);
}];
self.testString = @"yellow";

我收到错误日志:

2015-04-23 16:13:49.386 MyProjectName[69489:1451941] -[PlayViewController rac_valuesForKeyPath:observer:]: unrecognized selector sent to instance 0x7f987b4a0010
2015-04-23 16:13:49.443 MyProjectName[69489:1451941] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[PlayViewController rac_valuesForKeyPath:observer:]: unrecognized selector sent to instance 0x7f987b4a0010'

我看到他最终只是把它移植到一个工作项目,这是不必要的。任何帮助/问题将不胜感激。感谢

1 个答案:

答案 0 :(得分:0)

通过在$(inherited)中添加Build settings,向Other Linker flags添加$.ajax,调试&释放。