Making Your iOS Apps Fit for Consumption

Part of the Beginning iOS Programming For Dummies Cheat Sheet

iOS program performance is more than background processes. A few simple tricks can save time and increase performance. For the straight story, check out these hints.

Quickly finding and opening relevant files in Xcode

Use the Open Quickly command to find and open a file at a specific line, using its filename, type, or a symbol in the file (like a variable or function name), as follows:

  1. Choose File→ Open Quickly.

  2. In the search field, type characters in the name of the file or symbol you want to view.

  3. Type a dot followed by one or more characters of the filename extension.

  4. To have the file open at a specific line, type a colon followed by the line number.

  5. Choose a file from the results list.

This dialog also lets you decide where to place a file in Xcode. Just press and hold CMD+OPT+SHIFT while double-clicking the file.

Configuring behaviors

You can configure how Xcode responds to common events by setting its behavior using the Xcode→Preferences→Behavior settings page to set behavior preferences.

For example, you can have a certain set of tabs appear when Xcode runs your app. Or, if a build fails, you can make Xcode save a snapshot and open the debug area in your workspace window.

Creating a .gitignore file

Xcode can easily connect with git, a popular source code management system. If used without any configuration, git will try to archive everything in a project, even files with compiled object code, executables, and temporary files used by Xcode.

To fix this issue, you need to create configure git appropriately. To do this, navigate to the project folder and create a .gitignore file with the following content:

OS X Finder
.DS_Store
# Xcode per-user config
*.mode1
*.mode1v3
*.mode2v3
*.perspective
*.perspectivev3
*.pbxuser
*.xcworkspace
xcuserdata
# Build products
build/
*.o
*.LinkFileList
*.hmap
# Automatic backup files
*~.nib/
*.swp
*~ 

Popping up an Alert view

Your app often needs to pop up an alert to let the user know something happened and that she has a choice of actions. Here is a quick checklist for how to set up an alert.

  1. Implement the clickedButtonAtIndex method in the class that will cause the alert to pop up.

    The following example code shows you how:

        - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
            if (buttonIndex == 0){
                [self playNewGame];
            } else if (buttonIndex == 1) {
                return;
            }
        }
  2. Create, initialize, and show the alert.

    The following snippet of code shows you how:

    UIAlertView *alert = [[UIAlertView alloc] init];
    [alert setTitle:@"Game Over!"];
    [alert setMessage:@"Play Another Game?"];
    [alert addButtonWithTitle:@"Yes"];
    [alert addButtonWithTitle:@"No"];
    [alert setDelegate:self];
    [alert show];
  • Add a Comment
  • Print
  • Share
blog comments powered by Disqus

SERIES
Beginning iOS Programming For Dummies Cheat Sheet

Advertisement

Inside Dummies.com

Dummies.com Sweepstakes

Win $500. Easy.