Can we allocate a global memory to particular object or data which can be shared to all the application as available 'GlobalAlloc' in the cpp.
@interface NSNumberFormatter (Shared)
+ (NSNumberFormatter *) sharedNSNumberFormatter;
@end
@implementation NSNumberFormatter (Shared)
+ (NSNumberFormatter *) sharedNSNumberFormatter {
static NSNumberFormatter *shared = nil;
if (!shared) {
shared = [[NSNumberFormatter alloc] init];
}
return shared;
}
@end
But singletons live in the app space, by themselves they would be of little use for crossing app boundaries.
... which can be shared to all the application ...
Can we allocate a global memory to particular object or data which can be shared to all the application as available 'GlobalAlloc' in the cpp.
Shared to all the application (singular) would simply be malloc. I agree that the OP does not sound like a native English speaker, but there's no way in hell he's expecting anything to behave like Win16. I have no reason whatsoever to believe he wants to share memory between applications.
The way the cool kids share data across processes on UNIX and UNIX-alike systems (and even windows) is POSIX shared memory segments. I doubt very seriously that you'd be able to get an actual Objective-C object created in shared memory, copied there, etc. but you could serialize objects into primitive types, a struct, etc. and stick it into shared memory so it can be shared between processes. You will need to deal with locking (likely in the form of semaphores) to handle access to the shared area.
Look at the man pages for:
shmat, shmctl, shmdt, shm_open, shm_unlink, shmget
And:
http://www.opengroup.org/onlinepubs/007908799/xsh/ipc.html
for details.
The way the really cool kids do this is using Distributed Objects.
-Lee