Revision: 2745
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at April 11, 2007 11:44 by iloveitaly
Initial Code
#define APP_NAME [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"] #define APP_VERSION [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"] #define OPEN_URL(urlString) [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:urlString]] // Retrieving preference values #define PREF_KEY_VALUE(x) [[[NSUserDefaultsController sharedUserDefaultsController] values] valueForKey:(x)] #define PREF_KEY_BOOL(x) [(PREF_KEY_VALUE(x)) boolValue] #define PREF_SET_KEY_VALUE(x, y) [[[NSUserDefaultsController sharedUserDefaultsController] values] setValue:(y) forKey:(x)] #define PREF_OBSERVE_VALUE(x, y) [[NSUserDefaultsController sharedUserDefaultsController] addObserver:y forKeyPath:x options:NSKeyValueObservingOptionOld context:nil]; /* key, observer, object */ #define OB_OBSERVE_VALUE(x, y, z) [(z) addObserver:y forKeyPath:x options:NSKeyValueObservingOptionOld context:nil]; #ifdef __OBJC__ static inline BOOL isEmpty(id thing) { return thing == nil || ([thing respondsToSelector:@selector(length)] && [(NSData *)thing length] == 0) || ([thing respondsToSelector:@selector(count)] && [(NSArray *)thing count] == 0); } #endif
Initial URL
http://mabblog.com/source.html
Initial Description
Some macros that I use in many applications, provides an easy way to observe/retrieve preferences and access common application information
Initial Title
Useful Cocoa Macros
Initial Tags
Initial Language
Objective C