How good is it to use extern in Objective C? It does make coding for some parts easy.. but doesn\'t it spoil the object orientation?
Depends on your need, for example you have login page. After you logged in you are notifying to other pages in the applications.
#import
extern NSString *const DidLoginNotification;
@interface LoginViewController : NSObject
- (void)login;
@end
// LoginViewController.m
#import "LoginViewController.h"
//define extern const in implementation file only once for the whole process
NSString *const DidLoginNotification =
@"DidLoginNotificationNotified";
@implementation LoginViewController
- (void)login {
// Perform notification
[[NSNotificationCenter defaultCenter];
sendNotificationName: DidLoginNotification
object:nil];
}
The notification receiving party does not need to know the value of the const.