3

Is it possible for me to write an application that is supposed to be a wrapper around a few other applications and then run those apps inside my main app?

The idea is there's going to be a menu I just want to write once, but I want to integrate it as the very top layer of a number of other applications.

Another way I thought of is possibly creating a UIWindow at the top level and running it in there but I'm having issues passing touches through.

Thanks!

Brian L. Clark
  • 588
  • 5
  • 19
  • 6
    Not sure why this question is being voted down. It's a fine question, and a very interesting one. Even though this is the completely wrong approach, and is probably impossible. But curious none the less. That said, Brian, Matt Ball is right. Libraries seem to be what you want. – Josiah Mar 26 '13 at 00:10

2 Answers2

4

I think this is the wrong approach to take overall. If you want your code to be reusable, write a library.

Matt Ball
  • 354,903
  • 100
  • 647
  • 710
  • Okay, say I'm writing a library, do you know a good way i'd be able to run it on top of my application at all times? – Brian L. Clark Mar 26 '13 at 00:11
  • You're still not thinking about it the right way around. It's up to your application to use the library. The application controls the code contained in the library, and not vice versa. – Matt Ball Mar 26 '13 at 00:12
  • I know what you're saying, I want to build a library so that when you invoke it, it will have a button that will sit on the top of my apps at all times (even on top of alerts), as well all touches that don't hit the button should pass through to the app – Brian L. Clark Mar 26 '13 at 00:18
  • "on top" means "on top" .... nothing else! – user523234 Mar 26 '13 at 03:02
1

You can't host 'multiple applications' in one app, because as far as I know, Apple's sandbox prevents this, and only allows apps to run one at a time.

You have a couple options to emulate your desired functionality, though:

  • Use a UINavigationController or UITabViewController to navigate between different viewcontrollers, thus allowing the top level menu to lead to different 'functionalities' within the app. (meaning you don't really need to explicitly use UIWindow; you can use Storyboard and Storyboard segues to hook up these different functional parts) Advantage: it's all one app. Disadvantage: one listing on the app store.

  • Use custom URL schemes to move between two separate iOS apps. Every iOS app is (usually) its own project, (if you don't count 'targets', which can omit specific files from each build) and not every app is installed on every device. But assuming a customer has both of your apps, you could open one app from another using such a URL scheme, and even pass data. My own app uses a URL scheme to pass data from the 'lite' version to the 'pro' version. Advantage: multiple listings on the app store. Disadvantage: won't work if the user hasn't installed both apps.

  • Reuse the 'top level menu' code in multiple apps, and then do some logic so the app only uses the custom URL schemes when your other apps are installed. Then you could also lead them to the app store page for any apps they haven't installed yet. Advantage: multiple listings on the store, unified experience, and brings user to app store if the app isn't installed yet. (I haven't yet implemented code to check whether an app is installed... Looks like this question has been asked here.)

Edit: I read your other question. It looks like by 'top level' you mean something that is graphically sticky on the screen, and is not removed by other views as the user navigates the app? I'm not sure how to do this with Foundation, but you might be able to do it with Quartz2D (geared toward utility apps) or Cocos2D (geared toward games).

Community
  • 1
  • 1
Ben
  • 46
  • 4