Re: Debugging Bindings
Re: Debugging Bindings
- Subject: Re: Debugging Bindings
- From: Shawn Erickson <email@hidden>
- Date: Fri, 28 Jan 2005 08:06:46 -0800
On Jan 28, 2005, at 7:43 AM, David Olbersen wrote:
On Jan 28, 2005, at 12:30 AM, mmalcolm crawford wrote:
On Jan 28, 2005, at 12:22 AM, David Olbersen wrote:
3.B) The TWWorld tells the TWRobot to set it's location to where
the user clicked. ** The TWWorld then adds the TWRobot object to the
TWWorld's NSMutableArray (robots) using the addObjects: message **
First guess:
<http://homepage.mac.com/mmalc/CocoaExamples/controllers.html>
see "Programmatic modifications to arrays not noticed by table view".
w00t! No more "going behind the controller's back" for me! I've
replaced this simple code:
[robots addObject:newRobot];
with
NSMutableArray *tempRobots = robots;
[tempRobots addObject:newRobot];
[self setRobots:tempRobots];
and that works just fine.
As a nit-picky detail: is there any way I can get rid of the temporary
NSMutableArray? It's not like this list will get too large (no bigger
than a few hundered, generally in the dozens) but I'd like to avoid
the temporary variable if possible.
Just don't use the temp variable in the above since from the code you
posted it is doing absolutely nothing for you [1].
[robots addObject:newRobot];
[self setRobots: robots];
With that said I am not sure that is the best way to go about it after
looking over the section mmalcolm outlined in his prior email but if it
works well... it works. (I am not an expert of bindings so I won't
speculate on how one should really do it)
-Shawn
[1] (assuming the code you posted is really what you are using) It
makes me wonder if you fully understand the concept of objects in Cocoa
and how the different from variables referencing/pointing at said
object, don't take this the wrong way just as a hint to dig a little
deeper, I suggest
<http://developer.apple.com/documentation/Cocoa/Conceptual/
CocoaObjects/index.html> and all of the other documentation listed on
this page
<http://developer.apple.com/referencelibrary/API_Fundamentals/Cocoa-
fund-date.html>.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden