Question

I have recently purchased some source code of a mini game that I wish to include in my current complex application. However I am having difficulties actually implementing the mini game into my app. Initially I tried copying the source files into my project but stumbled across problems with having two separate app delegates. Is it possible to have two separate delegates?

Another method I though about was by adding the mini game project as an Xcode subproject. However I'm not sure if this is possible, and if it is, how would I go about doing so? If you know a better method, I would appreciate greatly any sort of help.

Thank you.

Était-ce utile?

La solution

You're going to need to do one of the following, depending on your specific needs and on whatever licenses may apply to this source code that you purchased:

  • Build a new app and copy some or all of the mini-game's source code into your app (or add that code as a subproject, but read on for more on that).
  • Take the existing mini-game's source code and modify it until it becomes what you need.

In both cases it's going to involve some understanding of the incoming source code, including its structure and operations. The best source for this information is probably the seller.

To answer some specific questions raised:

Can you run an iOS app within another iOS app with Xcode sub projects?

No. You can't run one iOS app inside of another, full stop. You can merge the source code from more than one app into one new app if you understand the code well enough.

I ... stumbled across problems with having two separate app delegates. Is it possible to have two separate delegates?

Not two app delegates. The app delegate is specifically the delegate object of the shared, singleton UIApplication object. Code-wise, the app delegate is the value of [[UIApplication sharedApplication] delegate]. That's not an array or other collection-- it's a single object. Most likely you're going to have to look at what the two app delegate classes do and merge their functionality into one.

(Italics above because "delegate" is a pattern used in many places in iOS development. You may well have many objects that are a delegate of one kind or another, but only one will be the app delegate).

Another method I though about was by adding the mini game project as an Xcode subproject. However I'm not sure if this is possible, and if it is, how would I go about doing so?

This is possible but it's not likely to be a solution to your problem. Subprojects are commonly used for external dependencies from different sources, like libraries or frameworks (e.g. if you were using AFNetworking you might choose to make it a subproject). That might be a good idea in your case (or might not, it's impossible to say without a lot more detail). But on its own it doesn't fix the problem of how to get this mini-game's functionality into your app.

Autres conseils

Copy the code over the mini game to your project, it will be a pain but it's the best way. The other option (which may not be possible) that I have not tested would be use container views to tap into the mini game classes.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top