How to have a shared integer variable in application

  • Hi,

    I have an application where I provide several plugins.

    I want to have the first plugin set an integer to start value and later
    allow all plugins to get/set this value.

    How do I do that?

    I tried with NSThread threadDictionary, but this one forgets values when
    I refersh my NSAutoRelease Pools.

    Also NSPasteboard seems not to work as the data is not per application.

    Any other idea?

    Some global Cocoa shared object list which I can use?

    Gruß
    Christian
  • On Oct 4, 2007, at 4:47 PM, Christian Schmitz wrote:

    > Some global Cocoa shared object list which I can use?

    Add it to your app delegate class and use:

    [[NSApp delegate] setMyInteger: value]

        - Scott
  • Have a singleton object and give that an attribute (or a dict)
    e.g
    [[GlobalPool defaultPool] setValue:x forKey:@"y"]; or something like
    that

    On 05.10.2007, at 01:47, Christian Schmitz wrote:

    > Hi,
    >
    > I have an application where I provide several plugins.
    >
    > I want to have the first plugin set an integer to start value and
    > later
    > allow all plugins to get/set this value.
    >
    > How do I do that?
    >
    > I tried with NSThread threadDictionary, but this one forgets values
    > when
    > I refersh my NSAutoRelease Pools.
    >
    > Also NSPasteboard seems not to work as the data is not per
    > application.
    >
    > Any other idea?
    >
    > Some global Cocoa shared object list which I can use?
    >
    > Gruß
    > Christian
  • Dominik Pich <Dominik...> wrote:

    > Have a singleton object and give that an attribute (or a dict)
    > e.g
    > [[GlobalPool defaultPool] setValue:x forKey:@"y"]; or something like
    > that

    I don't think Cocoa will like it if I load several modules with all the
    same class.

    I just need a pool like you suggested, but being part of the Cocoa
    framework.

    Gruß
    Christian
  • On Oct 4, 2007, at 5:27 PM, Christian Schmitz wrote:

    > Dominik Pich <Dominik...> wrote:
    >
    >> Have a singleton object and give that an attribute (or a dict) e.g
    >> [[GlobalPool defaultPool] setValue:x forKey:@"y"]; or something like
    >> that
    >
    > I don't think Cocoa will like it if I load several modules with all
    > the
    > same class.
    >
    > I just need a pool like you suggested, but being part of the Cocoa
    > framework.

    If you're not too hung up on exclusively using Cocoa, you could
    install your own Gestalt selector and then, with appropriate locking,
    modify the selector's contents. Under OS X, Gestalt is only process-
    wide vs its system-wide behavior under OS 6 through 9.

    steve
previous month october 2007 next month
MTWTFSS
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
Go to today