Re: Deleting from TableView and MutableArray
Re: Deleting from TableView and MutableArray
- Subject: Re: Deleting from TableView and MutableArray
- From: Dragan MiliÄ <email@hidden>
- Date: Wed, 14 Apr 2004 22:51:43 +0200
On 14. P_`, 2004, at 11:11, Stephane Sudre wrote:
>
On mercredi, avril 14, 2004, at 01:15 AM, Carl Sziebert wrote:
>
>
> Hi all:
>
>
>
> I am rather new to objective-c and am having trouble figuring out the
>
> correct way to do the following:
>
>
>
> My application has a table view that displays items which are a
>
> subset of a master mutable array. The issue that I am attempting to
>
> solve is when I choose an item in the table view and want to delete
>
> it. It should be removed from both the table view and the master
>
> array.
>
>
>
> Any advice is greatly appreciated.
>
>
- Remove the item from the array
>
>
- Call reloadData on the TableView
Well, I think it should take a little more than that (although it's
completely correct). You should keep your model, controller and view
objects separate. A deleteItemAction: action method of your controller
object (most probably an instance of NSWindowController class) should
be invoked, which in turn invokes deleteItem: method of your model
object, which actually removes item from the array and posts a
notification, caught by controller object, which responds to that
notification by updating user interface (and calling reloadData on the
TableView among other things).
I don't want this to sound like some kind of advertisement, but I think
that everyone intended to go deeper into Cocoa should try Bill
Cheeseman's book "Cocoa Recipes for Mac OS X", which explains in great
detail how to take advantage of Model-View-Controller (MVC) design
pattern, that Cocoa makes really easy to implement. All mentioned above
is explained in great detail in that book. I'm really happy that I took
an advice of a reader at cocoadev.com that this is the perfect SECOND
book to read that covers Cocoa (the FIRST one without any doubt is
Aaron's). It may look boring being dedicated to single project with
several check buttons, text fields, and other controls, but if you
understand the underpinnings, you'll be able to design and code your
apps in a way that makes extensions and modifications very easy
implementable.
Regards,
Milke.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.