-1

I'm making a tweak for jailbroken iPhones, and I have an object that I need to share between two processes. Currently, it is null in one process and contains information in another. How can I get around this?

Thanks!

Phillip
  • 1,205
  • 3
  • 15
  • 22
  • How are you currently sharing it? – trojanfoe Jun 18 '14 at 19:28
  • Currently, it's just a global variable. When I log it from one process, it holds info, and when I log it from another process, it's null. – Phillip Jun 18 '14 at 19:48
  • And you've no idea why that's the case? – trojanfoe Jun 18 '14 at 20:06
  • Well, I know that it's because the processes don't share the same memory space and therefor don't share the object's data, however what I *don't* know is how to actually share that object so they *do* share it. – Phillip Jun 18 '14 at 20:07
  • You could try Distributed Objects. – trojanfoe Jun 18 '14 at 20:10
  • Ugh. I just did a bit of research on distributed objects and they seemed like *exactly* what I was looking for, but unfortunately NSConnection isn't available on iPhone :( – Phillip Jun 19 '14 at 08:57
  • This question has already been answered here: http://stackoverflow.com/questions/9425706/share-data-between-two-or-more-iphone-applications – NightBits Sep 20 '14 at 12:29

1 Answers1

2

You should use NSUserDefaults:

Write them to memory as:

[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithDouble:variableName]forKey:@"giveItAName"]; 

Make sure it saves with: [NSUserDefaults synchronise];

And them use them again like this:

NSNumber *number = [[[NSUserDefaults standardUserDefaults] objectForKey@"giveItAName"]doubleValue];

I also think you should look up what a global is, you don't seem to know how to use them

Hope this helps