I'm developing two separated applications but there is a plist file for one of those app contains data that I need it on the other one.
is there is any way to get data? in case yes please show me some sample code? what about the NSUserDefault could it be useful?
NSUserDefault will not work. You need to create a custom URL scheme for your app and then you will be able to pass some data to your another app.
follow these url's you will find what you want.
http://www.tutoplanet.com/android-tutorials/ios-sdk-working-with-url-schemes/
http://iosdevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html
NSUserDefaults will not help you at all. Your applications are each sandboxed separately and have access to very little other than their own data.
You can, however, open a file from one app in another. You can see more about that here.
Other Resources
Apple Approved iPhone Inter-process Communication
2-way app integration on the iPhone: How it works
Related
I should hook UIResponder of every app, including SpringBoard and any others. In the hooking, I will write something to the specified file. If I set the path to /var/mobile/Library/MyApp, recommended by Cydia, I found that only the SpringBoard and MyApp could write successfully.
So is there a place every app can write and read?
I admit that I'm not 100% sure on this one, but my guess would be no, there is not a path that every app can writes files to on a jailbroken iPhone.
Certainly, jailbreak apps (installed in /Applications/) on a jailbroken phone can write to locations that can be shared between those jailbreak apps. But, as I understand your question, you would like to inject code into normal, App Store apps, so that those apps can also read and write to the shared location. That part I don't think is possible, because jailbreaking does not completely disable the sandbox for 3rd-party apps installed normally, under /var/mobile/Applications/.
Now, there might be a workaround. There are some shared folders that are accessible to all apps for certain purposes. For example, any app can write images to the saved photos album. What you could try is to take the content of the file you want to write, and encode it as fake image data, in a UIImage (e.g. with [UIImage imageWithData:]). You'd probably need to add a valid image header to the data. Then, you save the file to the photos album, using something like
writeImageToSavedPhotosAlbum:orientation:completionBlock:.
Another app could then find the fake photo by enumerating the saved photos album, and then converting the asset back to image representation to pull the real data back out.
However, this seems quite complicated, and possibly wouldn't work (I haven't tried it). Perhaps you could tell us why you want this shared file. Maybe there's a better way to share the data, without using a globally-accessible file?
Notifications can help you with this. Every app will send interprocess notifications about the events. You could start a daemon that will listen for this notifications and save them in a file. Or you could listen for them in SpringBoard as he can write, for example, to /var/mobile/Media. Depends on what you want to do with this file. Check out my answer here How to create a global environment variable that can be accessed by SpringBoard or other applications in the jailbroken iPhone?
Are CFPreferences across iPhone app readable?
In other words, can I write a NSUserDefaults style preference to disk and have it be readable in another iPhone app, if, for example, I didn't write this app, and am working from a static library?
I fear the answer is No. Period. Full stop. Any thoughts?
No. Apps have their own sandbox; you cannot interact between them in the manner you describe. As of iOS4, inter-app communication is quite limited.
One workaround is to use the keychain for storing small amounts of shared data, but there are many limitations to this method. You have to use the same id between applications and that precludes you from using push notifications and other features.
Alternatively, you could support Dropbox or something similar and store the shared information on the internet.
Neither is a great solution.
I do have an Idea to integrate with my application. I want to create multiple application within a single one application.
Like
and application containing Weather application as well as image processing application + camera based application.
I want to know Is this thing possible with iphone application?
Please suggest me is this possible with iPhone app development and is it allowed by apple or not.
thanks for your suggestion in advance.
Consider these things as features. Weather information is a feature, image processing is another and camera in another. You can create any number of features in your app. If that is what you have meant by application then that is technically possible and seems also OK with Apple. This is not 3 different applications, rather it's one application with three different features. No matter how many features you have, iOS will treat that as a single application(a single app bundle with a single executable file).
But if are asking whether there is any way to combine separate applications(separate projects, separate app bundles with separate executables) then that is not possible.
Note: Personally I think adding completely different features in a single app is not a good idea.
Go to App Store and search for this app, App Tool Box - All in One. It's exactly the same structure as you mentioned in your post. And it only costs $0.99.
Sure, you can do it. I don't think Apple has anything against an app that does more than one thing. As long as none of those things breaks any of their rules.
It is possible to store some application files and share it with another application?
Can application A remove files created in such shared space by application B?
In general, no. There are a few things you can consider.
All apps can read/write/share photos via the user's photos library.
Some apps have been known to share data via the address book. That is, they put data in a special address card which can be read by multiple apps.
If the apps have matching App ID bundle seeds, they can access the same keychain entries. I'm not sure how much data can be stored in the keychain, but it is possible to share data this way.
Apps can pass data to each other via a launch URL. That is, one app can ask iOS to open a URL that launches the next app, and that URL can have parameters that pass data.
No, each application has its own sandbox. Only way to communicate is to use custom URLs to call the other application or have a 'middle man' (eg a computer).
As an alternative to RupertP's answer, the only real work-around is to use a globally-accessible server. A lot of iOS devs use MobileMe's iDisk (not free) or DropBox (free for a limited account).
Is there a way to have an app write a into a file and then have another app read from that file?
I mean writting into the file system of the iPhone.
I want to do this without using an internet connection. So uploading the file and then downloading from the other app is not what i mean.
Thanks!
It appears that there are ways you can, but it won't get approved by Apple if you do.
See http://blogs.oreilly.com/iphone/2008/09/sandbox-think-like-apple.html for more information.
The current sand boxing of applications does not allow this, however it appears that this may be available in future iPhone OS versions. Reference
I'm not sure exactly what circumstances you're in here, but you could register app B as a handler for a particular protocol, and have app A try to open such a link (e.g. appB://yourinfohere). It depends on how much data you want to transfer and many other things, but it might work.