IPHONE: IBAction and IBOutlet

Sometimes when all you need is a simple UI application that doesn't require too much customization or skinning, you can try building the application in Interface Builder.

Step 1: Create a New Project (Apple+Shift+N) > View-Based Application, name the application IBTest



Step 2: Edit the default IBTestViewController.h & .m files. Add the following lines in the appropriate places:

IBOutlet UIButton* button; IBOutlet UILabel* label; - (IBAction)userPressedButton:(id)sender;



Step 3: Open MainWindow.xib w/ Interface Builder

Step 4: Double-Click Test View Controller and a window will pop up



Step 5a: Add a View (from the library: APPLE+L) to Test View Controller
Step 5b: Add a Rounded Rect Button to the View you just added
Step 5c: Add a Label to the View you just added


Step 6: Link your UIButton & UILabel to the button and label you just added. You can do this by Apple+Right-Clicking the Rounded Rect Button & drag your mouse onto the Test View Controller



Step 7: Select userPressedButton in the popup


Done... your code is now hooked up through the interface builder. When users click the button, your userPressedButtons method will fire, as expected.

IPHONE: Removing the GLOSS from the app icon

Edit the Info.plist file...

UIPrerenderedIcon = true

In plain text:

UIPrerenderedIcon

IPHONE: Changing the Product Name

If your single source produces multiple 'products', ie. *.app's, it may be necessary to differentiate the 2 by designating the product names.

To create 2 products from 1 source:
- Create a new target by making a copy of the first.
- Modify this target by changing its Info.plist (by default will be Info Copy.plist)
- Modify its displayed name by changing its Infoplist.strings
- Optionally you can add a PREPROCCESSOR MACRO to differentiate the 2 targets (see previous post)

But when you compile the 2 targets, they always have the same .app name. This could be problematic for multiple reasons...
- If your bundle identifier is com.xxx.Application, your Product name should be 'Application'
- If you want to differentiate the 2 builds, it'd be easier if the 2 did not have the same app name

To do so:
- Highlight the Targets > Application 1
- Right click > Get Info
- Build tab
- Packaging > Product Name = New Application name

IPHONE: Environment Variables & #define directives

To use Configuration-defined #defines

Step 1: Right click on the project/target and select Get Info.

Step 2: Under the Build tab, select the Configuration you want to associate the #define with (ie. Debug/Release)

Step 3: Under User-Defined (Setting) all the way at the bottom, find a field that's called

GCC_PREPROCESSOR_DEFINITIONS

Step 4: If a field doesn't already exist, create it by clicking on the Gear on the bottom left & selecting Add User-Defined Setting.

Step 5: For the VALUE, input your #define variable. (ie. TEST_DEFINES)

Step 6: Now in code you can use

#ifdef TEST_DEFINES
... do something
#else
... do something
#endif