我在我的iOS应用程序中有一块代码,我必须在每个视图中使用 - 不能将其放在函数/方法中 - 所以我想知道是否有任何方法可以使用 #define 并在需要的地方使用其标识符。以下是示例代码。
我想要用 #define 标识符替换的代码:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(_gotECSlidingViewAnchorRightOrRightrNotification)
name:ECSlidingViewTopDidAnchorLeft
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(_gotECSlidingViewAnchorRightOrRightrNotification)
name:ECSlidingViewTopDidAnchorRight
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(_gotECSlidingViewTopDidResetNotification)
name:ECSlidingViewTopDidReset
object:nil];
所以我想知道如何在ViewDidLoad方法中定义并使用它。