2008年2月29日 星期五

NSString and NSMutableString

use @"abc" to mean NSString
ex: NSString *str = @"Hello";

use content of file to create NSString
ex: NSString *str = [NSString stringWithContentsOfFile:@"/path/to/file"]

use c characters to create NSString
ex: char *cStr="hello";
NSString *str = [NSString stringWithCString: cStr]

get length of NSString
ex: unsigned int strLen = [str length]

append on NSString to another
ex: NSString *str = @"Hello";
NSString *str2 = [str stringByAppendingString: @"abc"]

append a format:
ex: NSString *str3 = [str2 stringByAppendingFormat: @"%d", 2003]

search for subString:
ex: NSRange loc = [str rangeOfString:@"The"]

what is NSRange:
typedef struct _NSRange{
unsigned int location;
unsigned int length;
}NSRange;

breaking a string into components:
ex: NSArray *fields = [str componentsSeperatedByString:@"abc"];

create NSMutableString from NSString:
ex: NSString *str = @"hello";
NSMutableString *ms = [NSMutableString stringWithString: str];

mutable and immutable

immutable class means you can not alter after initialization
ex: NSString, NSArray

mutable class means you can alter after initialization, it extends from immutable class
ex: NSMutableString, MSMutableArray

2008年2月28日 星期四

ButtonGroup

同一個group裡的button,只有一個會被選。

how to use:
1. create ButtonGroup object
2. add buttons to ButtonGroup object

目前時間 in java

利用Calendar class
java.util.Calendar

ex: 顯示目前幾點
Calendar.getInstance().get(Calendar.HOUR_OF_DAY)
顯示目前幾分
Calendar.getInstance().get(Calendar.MINUTE)

icon composer

create software's icon

/Developer/Applications/Utilities

how to set application's icon:
modify info.plist
ex:
CFBundleIconFile
APPL

xcode 指令

在function名稱上,option+double click:
show document to explain the function

在function名稱上,apple + double click:
show the function's header file

2008年2月27日 星期三

mvc

mvc( model, view, controller)

model: 實際做的function,例如1加到100
view: user看到的GUI

controller: 讓view和model能溝通,使得model運算的結果可以更新到view上,例如更新在text field上。