Xcode 4.6 available

Yesterday, Apple released version 4.6 of Xcode which is now available form the Mac App Store.

The release notes for 4.6 read:

  • Includes SDKs for OS X 10. Mountain Lion and iOS 6.1.
  • Code completion heuristics are more accurate, and use an optimized default data set.
  • New compiler warnings help identify potential bugs when using ARC and weak references.
  • C++ 11 support for ‘user defined literals’ and ‘unrestricted unions’ features.
  • Debugger can inspect elements within NSArray or NSDictionary objects.
  • Analyze now performs deeper cross-function static analysis of Objective-C and C++ code.
  • The number of indexing passes is reduced due to improved dependency checking.
  • Additional bug fixes and stability improvements.

Tiling an image background in an iOS application

To change the background image of an iOS application, one of the simplest methods is to add a UIImageView component onto the application, set its Image property and then send the UIImageView to the background.

This technique works well and doesn’t require any coding, but the image has to be big enough to cover the entire  screen area of the application.  The image can be stretched to cover the application background, but not tiled. Sometimes this looks OK, but if you want to tile and image onto the applications background, setting the application’s bachgroundColor (yes, color!) property is what’s needed.

In the view’s controller class, add a viewDidLoad method and set the view’s backgroundColor property to a UIColor instantiated with the colorWithPatternImage selector. For example,

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor =
        [UIColor colorWithPatternImage: [UIImage imageNamed:@"tile.png"]];
}

Changing the z-order on components in Xcode

When you’ve added components into the interface builder in Xcode for an iOS application, you sometimes want to change the z-order and make components go to the top of the back. This can be particularly useful, for example, if you are adding an Image View to act as the application’s background image.

To change a component’s z-order, select the component in the storyboard and the choose the “Editor > Arrange” menu item and select from:

  • Send to Front
  • Send to Back
  • Send Forward
  • Send Backward