Tuesday, March 30, 2010

Graphics ok in Simulator, not found in Real Device

This is one of the ways that simulator and real device differ: check the names of your graphics files.

Filenames are case-sensitive in real device, not in emulator.

SpringBoard failed to launch application with error code: 7

Set up a system where same sources can produce two different applications, one for release and another for testing. The requirement was they have to be able to exist at the same time in device.

Added a second ad hoc distribution provisioning profile with new bundle identifier. Somehow simulator failed to run the application(s) any more.

Close simulator, go to Xcode menu and select "Empty caches..." menu item. Might as well "Clean All Targets" just in case.

Monday, March 22, 2010

Property 'username' attribute in 'ConnectApi' class continuation does not match 'ConnectApi' class property

Want to declare external API as readonly, while internal has to be writable. Done this before, but right now something doesn't work.

Turned out that the reason is missmatch in unwritten default values. The property types must match in both external and internal declaration, including the non-written default values. This is the correct version:
@interface ConnectApi : NSObject
    NSString *username;
@property (nonatomic, copy, readonly) NSString *username;
@interface ConnectApi ()
@property (nonatomic, copy, readwrite) NSString *username;

Friday, March 19, 2010

Accessing Unknown 'backgroundColor' Component of a Property

Embarrassing problem. Forgot to import the header file or add class forward declaration. Somehow you'd expect those to happen automatically, don't you think?

Code works as-is right after import has been done. Just adding this reminder for google to find next time.

Tuesday, March 16, 2010

Changing Name of "Edit" UIBarButtonItem

If you use default UIToolbar "Edit" button provided by Interface Builder, you cannot change the name from code. You have to change UIBarButtonItem identifier to "Custom" and title as "Edit". Then add this delegate code:

- (IBAction)setEditing:(BOOL)editing animated:(BOOL)animated
    [self.myController.myView setEditing: !self.myController.myView.editing animated:YES];
    if (self.myController.myView.editing)
        self.editButton.title = @"Done";
        self.editButton.style = UIBarButtonItemStyleDone;
        self.editButton.title = @"Edit";
        self.editButton.style = UIBarButtonItemStyleBordered;
Don't forget to hardcode button width at 43 pixels, otherwise change of button title will shift position of following items on toolbar. That 43 pixels is the default width of standard Edit button and wide enough to show longer "Done" text string.

Monday, March 15, 2010

Interface Builder cannot change UIView color

If you fail to change UIView color in Interface Builder, it could be because Emulator is blocking your changes. Close emulator and try again.

Thursday, March 4, 2010

Unversioned Directory Already Exists in SVN Repository

SVN error note "Failed to add directory 'trunk/build': an unversioned directory of the same name already exists" means that your locally ignored directory has been added under version control. Maybe someone else did it, maybe you did it initially before deciding to ignore.

The fix is to remove those directories from version control. There's nothing you can do locally to fix it, you have to access the main, common, shared repository in network. Remove the directories, do refresh and updates.

Reminder how to ignore directories locally: go to folder (trunk), which contains directory (build) you want to ignore. Do command line "svn propedit svn:ignore" and make sure your list contains all the directories to be ignored.

If that command doesn't work (bash), define your editor as "export EDITOR=emacs" or whatever is your favorite editor. Control-x Control-c exits from emacs, in case you get stuck.

svn status, svn update and svn cleanup might help, too. Remember to read SVN manual BEFORE using any of those commands. You have been warned, all caused problems are own own responsibility.

Monday, March 1, 2010

How to Create a Black Statusbar

When you open MainWindow.xib in Interface Builder, you can find "Window - Status Bar" and "MainViewController - Status Bar". Setting either one or both as "Black" doesn't seem to have any effect on the actual application. Your statusbar remains gray.

So how do I get a black statusbar?

Open your application .plist file, click on plus icon (+) to create a new row and write "Status bar style" as name and select "Opaque black style" as value.

Those are "key = UIStatusBarStyle" and "string = UIStatusBarStyleOpaqueBlack if you're more familiar with that style.