2008年9月16日 星期二

novamind

mind mapping software

mount iso

hdiutil mount  test.iso

crossover

execute windows software 

2008年9月13日 星期六

@property & @synthesize

@property :
define getter  & setter method
ex:
@property(readwrite, assign)  int test;

@synthesize:
implement getter & setter method
ex:
@synthesize test;

binding

ex:
binding Slider's value to a key, then slider's value will sync with key

How to do:
In slider's inspect, set its binding 
(1)set bind to class A
(2)set A's  test member as model key path

key value coding

ex:
.h檔

@interface AppController : NSObject {

int test;

}

@end


.m檔

// set test

[self setValue:[NSNumber numberWithInt:5]

forKey:@"test"];

// get test

NSNumber *n=[self valueForKey:@"test"];


// is called when valueForKey is called

-(int)test

{

NSLog(@"test is returning %d", fido);

return fido;

}


// is called when setValue is called

-(void)setTest:(int)x

{

NSLog(@"setTest is called with %d", x);

fido=x;

}



delegate

if B is delegate of A,  when something happens to A,  B's method is called

ex:
B is  TableView's delegate 
B implement following method:
-(void)tableViewSelectionDidChange:(NSNotification*)notification 
when the selection row is table is changed ,  this method is called

NSTableView

data source:
decide the content of the table
implement two methods:
-(int)numberOfRowInTableView:(NSTableView*)tv

-(id)tableView:(NSTableView*)tv
                           objectValueForTableColumn:(NSTableColumn*)tableColumn
                           row:(int)row

NSWindow

initialFirstResponder outlet:
this outlet decides which view should be receiving keyboard events when window appears 

NSButton, NSSlider

NSButton:
oval button, square button ,  check box

methods:
-(void)setEnabled:(BOOL)yn

-(int)state
if return NSOnState(1), the check box is on
if return NSOffState(0), the check box is off

-(void)setState:(int)aState

NSSlider:
-(void)setFloatValue:(float)x

-(float)floatValue

NSTextField:
-(NSString*)stringValue

-(void)setStringValue:(NSString*)aString

NSFormatter can convert a string into another type , and vice versa
-(NSObject*) objectValue

-(void)setObjectValue:(NSObject*)obj