Every once in a while Eclipse decides to go and be a little shit and repeatedly ask you for your SVN password, despite the fact that it’s already been saved.

For me, this started when an SVN server went down for a nanosecond and Eclipse obviously thought I’d wronged it somehow. From then on, every time I interacted with SVN I was prompted for my credentials.

After some Googling, I came across this article, which offered up the brilliantly simple suggestion of deleting the Eclipse keyring.

Spoilers – it worked. However the article is a few years old and Eclipse has since changed how they store password data.

Here’s what to delete on OS X, for Eclipse Indigo (3.7.x):

~/.eclipse_keyring


You should make a backup just in case, but the next time Eclipse asks for your SVN password you should notice that both fields (username and password) are blank now, and if you save the credentials this time they’ll stay saved.

Here’s a weird one for you. I found out today that apparently you can’t interact with a single SimpleButton instance in both normal and fullscreen modes in an app. It literally won’t work.

Let’s say you have a SimpleButton that serves as the play button for an app that displays video. If you launch the app and click on the button before going fullscreen, the SimpleButton will only respond to subsequent clicks when in normal mode.

However the reverse is also true. If you launch the app and click on the button only after going fullscreen, the SimpleButton will only respond to subsequent clicks when in fullscreen mode.

I checked my code thoroughly to make sure I wasn’t accidentally disabling the SimpleButton when I changed display states, but alas… nothing. In the end I had to create separate buttons for each state, mirror any changes, and then swap them when the display state changed.

Here’s the relevant code snippets:

stage.addEventListener (FullScreenEvent.FULL_SCREEN,
    onDisplayStateChanged);

public function onDisplayStateChanged (event : FullScreenEvent) : void
{
    if (stage.displayState == StageDisplayState.FULL_SCREEN)
    {
        addChildAt (fullscreenPlayButton, getChildIndex (playButton));
        removeChild (playButton);
    }
    else
    {
        addChildAt (playButton, getChildIndex (fullscreenPlayButton));
        removeChild (fullscreenPlayButton);
    }
}


I still have no idea why this occurs, but there you go.

Let’s say you build a simple animation in CS5.5 – like a loading indicator – how do you embed and use it in your Flex or Flash application?

First, let’s take a look at the animation. Assuming you don’t need to load it at runtime (and it’s a reasonable size), you can easily embed a SWF animation in a custom class:

[Embed(source="/loading.swf", mimeType="application/octet-stream")]
public var LoadingAnimation : Class;


Specifying a mimeType of “application/octet-stream” is important here, because it allows any file type to be used and gives you a ByteArray for the embedded object.

Next, you need to create a LoaderContext in order to use the embedded SWF as an animation and to execute code (if needed):

// allows us to import SWFs to use as animations
var context : LoaderContext = new LoaderContext (false,
    ApplicationDomain.currentDomain);
context.allowCodeImport = true;

var loader : Loader = new Loader ();
loader.loadBytes (new LoadingAnimation (), context);


Once you’ve loaded the embedded animation, simply add the Loader object to the stage and you’re done!

By default, you can’t pad or add margins to a UILabel. You have to apply custom insets (fancy for “margins”) in order to do so, and it’s repetitive and annoying in practice.

So I built a custom class – UIBorderLabel – to automate the process. You treat it just like a regular UILabel, except you can specify a numeric value for each margin.

Here’s the header file:

#import

@interface UIBorderLabel : UILabel
{
    CGFloat topInset;
    CGFloat leftInset;
    CGFloat bottomInset;
    CGFloat rightInset;
}

@property (nonatomic) CGFloat topInset;
@property (nonatomic) CGFloat leftInset;
@property (nonatomic) CGFloat bottomInset;
@property (nonatomic) CGFloat rightInset;

@end


And the corresponding implementation:

#import "UIBorderLabel.h"

@implementation UIBorderLabel

@synthesize topInset, leftInset, bottomInset, rightInset;

– (void)drawTextInRect:(CGRect)rect
{
    UIEdgeInsets insets = {self.topInset, self.leftInset,
        self.bottomInset, self.rightInset};

    return [super drawTextInRect:UIEdgeInsetsInsetRect(rect, insets)];
}

@end


To use, specify the insets immediately after you create the UIBorderLabel:

UIBorderLabel *myBorderLabel = [[UIBorderLabel alloc] init];

myBorderLabel.topInset = 10;
myBorderLabel.leftInset = 15;
myBorderLabel.bottomInset = 10;
myBorderLabel.rightInset = 15;


Here’s the result. In the example below, “Relax” is a UIBorderLabel with a 20-pixel margin on all sides.


UILabel with Custom Insets

(screenshot is from Travel Rules, and used with implicit permission since I wrote it)😉

When a cell in a UITableView leads to a subview, it can be useful to have some added visual context. A disclosure indicator in a UITableViewCell is a small chevron displayed at the right edge to visually indicate that it leads somewhere.

For example, take a look at the “History” folder in the Mobile Safari Bookmarks:


iOS Safari Bookmarks

Nifty, right? Here’s how to do it:

– (UITableViewCell *)tableView:(UITableView *)tableView
    cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView
        dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil)
    {
        cell = [[[UITableViewCell alloc]
            initWithStyle:UITableViewCellStyleDefault
            reuseIdentifier:CellIdentifier] autorelease];
    }

    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

    return cell;
}


Keep in mind that a disclosure indicator is merely for visual context; it doesn’t actually do anything. You still have to implement the subview you want to display.