On Sep 23, 2008, at 10:22, Eric Lee wrote:

Using bindings, how do you add an object (a textfield's string to be specific) to a NSMutableArray so that a table view can show the object?


You need to modify the array in a KVO-compliant manner, which means the array needs to be a property of some object in your data model. Then use:

[[myDataModelObject mutableArrayValueForKey: @"myArray"] addObject: newString];

In the simplest case, the array can just be an instance variable of the data model object, since KVC is capable of finding instance variables directly:

        @interface MyDataModel ... {
                NSMutableArray* myArray;
                ...
        }

Or it can be a genuine property:

        @interface MyDataModel ... {
        ...
        }
        @property (...) NSArray* myArray;

with a suitable implementation in MyDataModel.


_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to