Daniel G. Wilson
Daniel G. Wilson

Reputation: 15055

Handling different xib files for a lite and full version

I have a bunch of xib files that I use in my app's full version. In the lite version I want to be able to load some xibs that have less features, thus making it a lite version. All my viewControllers are hooked up in IB, and are referenced by both targets at the moment.

What's the best way to hide functionality beyond simply disabling it? I figured that having an entirely different xib file would be easiest, am I wrong?

Edit:

To clarify, I'm trying to figure out how to load a different nib for a view controller depending on the version. I believe it has something to do with initWithNib.

Upvotes: 0

Views: 405

Answers (2)

rckoenes
rckoenes

Reputation: 69489

Use targets, you can exclude/include files per target.

Create a target for lite, which does not include some parts that the full app wil, like load a NIB which has les functionality than the full version.

You can even use the same names for code files (.m) and NIB and include/exclude via the target property.

This will only work if you have a lite and full version in the app store.

If you want a in app purchase then you will need to do what @Jack Humphries suggests.

Upvotes: 2

Jack Humphries
Jack Humphries

Reputation: 13267

Yes, you are right, having different XIBs in my opinion would be easier. So, the full and lite versions are in the same app with an in app purchase? I would have a generic home page, and then use NSUserDefaults to link to different pages. For example, here is the code for a button:

-(IBAction)gotogame {

if ([[NSUserDefaults standardUserDefaults] boolForKey"@Purchased"] == YES) {
    //go to the entire game XIB
}
else {
    //go to the lite game
}

Here is how you set NSUserDefaults:

[[NSUserDefaults standardUserDefaults] setBool:YES forKey"@Purchased"];

Additionally, if you want everything in the same view, use NSUserDefaults, and if the Purchased key is equal to yes, then do this:

[litePicture setHidden:YES];
[fullPicture setHidden:NO];

And vice versa. Let me know if you have any questions!

Upvotes: 1

Related Questions