2012年3月29日 星期四

[Linux] Lock shell script

By using mkdir, it is a atomic lock.

Lock your script (against parallel run)

2012年3月23日 星期五

[iOS] Events in iOS

Event Handling Guide for iOS

2012年3月11日 星期日

[iOS] UIAlertView

UIAlert View with multiple options.

in .h: include UIAlertViewDelegate


@interface MyController : UIViewController <UIAlertViewDelegate> {
}

in .m: implement delegate for UIAlertViewDelegate


#pragma UIAlertView
- (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
    NSLog(@"%d", buttonIndex);

[iOS] UIActionSheet

UIActionSheet Class Reference
Move Cancel Button from top to bottom

In .h: include UIAlertViewDelegate

@interface MyController : UIViewController <UIAlertViewDelegate> {
}


In .m: implement delegates

- (void) ShowActionSheet:(NSString *)title {
    UIActionSheet *actionSheet = [[UIActionSheet alloc
                                  initWithTitle:title
                                  delegate:self
                                  cancelButtonTitle:nil
                                  destructiveButtonTitle:nil 
                                  otherButtonTitles: nil];
    
    [actionSheet addButtonWithTitle:@"Option 1"];
    [actionSheet addButtonWithTitle:@"Option 2"];
    [actionSheet addButtonWithTitle:@"Option 3"];

    [actionSheet addButtonWithTitle:@"Cancel"];
    actionSheet.cancelButtonIndex = actionSheet.numberOfButtons;
    
    [actionSheet showInView:self.view];
    [actionSheet release];
}

- (void) actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
    NSLog(@"title=%@, buttonIndex: %d, cancelButtonIndex: %d, firstOtherButtonIndex: %d",
          actionSheet.title,
          buttonIndex, 
          actionSheet.cancelButtonIndex
          actionSheet.firstOtherButtonIndex);
}


2012年3月9日 星期五