tags:

views:

72

answers:

1

i want to implement NSForm view in my application i am new in cocoas application.can you advice me about this controller?Thanks in advance.

+1  A: 

There are different ways you can use NSForm in your application.

  1. Adding NSForm in your nib file
  2. Create NSForm by programming and attach that NSform in your view of window.

@2 I have one example with me with which you can understand

NSWindow*window = [self window]; // gets current widnow NSView *theContentView = [window contentView]; // gets view from window

NSRect contentRect = [theContentView frame]; // gets frame from view

NSRect formRect = NSMakeRect( 0, 50, 300, 220 ); // creates new frame

NSForm *theForm; theForm = [[NSForm alloc] initWithFrame:formRect]; // init with frame fromRect

NSFormCell *theFormCell; // create cell for form

// defines first cell with field First Name theFormCell = [theForm addEntry:@"First Name:"]; [theFormCell setTag:EContactFieldTag_FirstName];

// defines first cell with field Last Name
theFormCell = [theForm addEntry:@"Last Name:"]; [theFormCell setTag:EContactFieldTag_LastName];

[theForm setCellSize:NSMakeSize( 300, 25 )]; // defines size for cell [theForm sizeToCells];

[theForm setKeyCell:theFormCell]; // assign cell to form

[theContentView addSubview:theForm]; // add form to current view

I think this should help you get started.

Let me know if you have any questions.

yes thank its working fine.Now i want to get NSFormcell value in one array how it possible?
mikw
You can create one array and loop through it and have you cell created likeNSInteger i = 0;for(id *item in array_data) {theFormCell = [theForm addEntry:(NSString *) item];[theFormCell setStringValue:[[NSString alloc] initWithFormat:@"%d", i]];[theFormCell setTag:i]; // have tag diff for all nscell i++;}this will generate cell for all items in array and put i value in them.