2014年7月24日 星期四

[Xcode] Enable/disable a button

@property (retain, nonatomic) IBOutlet UIButton *btnButton;
enable/disable like this in .m file:
btnButton.enabled = NO; // disable button
btnButton.enabled = YES; // enable button

2014年7月16日 星期三

[Xcode] How to quit the application when the window closes

If you want an application to quit (terminate) when the window is closed, you can do this:

-(BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication*)theApplication
{
    return YES;
}

2014年7月14日 星期一

[Xcode] How to convert between NSTextField and NSString

// NSString --> NSTextField
NSTextField * txtField = [[NSTextField alloc] init];
NSString *str = @“1234”;
txtField.stringValue = str;

// NSTextField --> NSString
NSString *str1 = txtField.stringValue;

[Xcode] How to convert byte array to NSString

Byte* btData = new Byte[12];
memset(btData, 0, sizeof(Byte) * 12);
...

NSData *data = [NSData dataWithBytes:btData length:sizeof(btData)];
NSString *string = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];

2014年7月2日 星期三

[Xcode] Hotkey

command + X
- cut

command + C
- copy

command  + V
- paste

command + A
- select all

command + /
- add/remove comment

command + \
- add/remove breakpoint

command + R
- run

command + B
- build

command + F
- find

shift + command + F
- find in project

command + option + F
- find and replace

shift + command + option + F
- find and replace in project

2014年6月11日 星期三

[Mac OS] How To Capture a Screen Shot with Mac OS X

1. Command+Shift+3
   To capture the entire desktop, and then will be automatically saved as a PNG file on your desktop.

2. Command+Control+Shift+3
   To copy the entire desktop, and then will be placed on your clipboard for you to paste into another program.

3. Command+Shift+4
    To capture a portion of the desktop. A cross-hair cursor will appear and you can click and drag to select the area you wish to capture. When you release the mouse button, the screen shot will be automatically saved as a PNG file on your desktop. (The file is saved as PDF in Mac OS 10.3 and earlier.)

4. Command+Shift+4, then press the Spacebar
   To capture a specific application window. The cursor will change to a camera, and you can move it around the screen. As you move the cursor over an application window, the window will be highlighted. The entire window does not need to be visible for you to capture it. When you have the cursor over a window you want to capture, just click the mouse button and the screen shot will be saved as a PNG file on your desktop. (The file is saved as PDF in Mac OS 10.3 and earlier.)