在app

时间:2016-10-12 13:03:12

标签: ios objective-c cocoapods

我有一个包含.h和.m文件的cocoapod。在其中一个.h文件中,我执行以下代码,以定义字符串常量:

#import <Foundation/Foundation.h>

extern NSString * const MURDatabaseUpdatedNotification;
extern NSString * const MURDatabaseReadyNotification;

@interface MURDatabaseSingleton : NSObject
...

在相应的.m文件中,我声明了常量如下:

#import <UIKit/UIKit.h>
#import "MURDatabaseSingleton.h"

NSString * const MURDatabaseUpdatedNotification = @"MURDatabaseUpdatedNotification";
NSString * const MURDatabaseReadyNotification = @"MURDatabaseReadyNotification";

@interface MURDatabaseSingleton ()
...

到目前为止,这么好。在.m文件中,我可以使用其中一个定义的字符串以完美的方式触发带有名称的Notifications。 除此之外,在我的应用中使用此作为cocoapod,MURDatabaseReadyNotificationMURDatabaseUpdatedNotification突然变为零。捕获通知告诉我他们使用正确的名称被解雇,但常量是零。

NSLog(@"MURDatabaseReadyNotification: %@", MURDatabaseReadyNotification);

我现在在这个愚蠢的问题上挣扎了几个小时,我希望有人可以帮助我。谢谢!

enter image description here

1 个答案:

答案 0 :(得分:0)

在调查了几个小时的问题后,我发现问题是一种缓存问题。我试图添加另一个新常量并尝试访问它,但编译器突然报告,这个新常量甚至没有声明。

我在 / Users / pgrundner / Library / Developer / Xcode / DerivedData / - 中找到了过时的构建数据。即使清理项目也没有更新此目录中的旧内容。然而,删除DerivedData中的应用程序目录是解决方案。