First of all, I’m using ARC.
If I have a class that, for example, looks like this:
static CFNumberRef numberRef = NULL;
+ (void)initialize {
float myFloat = 28.37202;
numberRef = CFNumberCreate(kCFAllocatorDefault, CFNumberFloatType, &myFloat);
}
How would I go about releasing numberRef?
Since the pattern you’re using resembles the way singletons are created and managed, I’d say you can treat your object as an actual singleton. This means that you don’t need to release it. (Think a bit about it – personally, I have never seen a singleton implementation in Objective-C/Cocoa that would have cared about releasing the shared instance). This behavior is in accordance with the fact that you need the object to be alive throughout the lifetime of your application. So don’t release it at all – when the process terminates, the kernel will make sure to clean up all the resources it acquired.