• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSArrayController and bindings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSArrayController and bindings


  • Subject: Re: NSArrayController and bindings
  • From: Peter Wollschlaeger <email@hidden>
  • Date: Tue, 24 Feb 2004 22:43:50 +0100

Am 24.02.2004 um 21:29 schrieb mmalcolm crawford:

> On Feb 24, 2004, at 11:56 AM, Rob Borsuk wrote:
>> I would first like to use it in a Cocoa Application not a document
>> based application. Is that okay?
>
> Yes.
>
>> I would like to be able to count the dictionary objects but it
>> doesn't seem that NSArrayController (though using 'Array' in the
>> name) has a 'count' method.
>
> Use the array operator @count.
>
>> I would like to be able to write the "array" out as a text file
>> (viola - plist) but it seems that it likes to save as a encoded
>> format.
>>
> In the most likely scenario, the NSController is simply managing the
> *display* of the array, the array itself is still managed by a classic
> custom "controller" which should be responsible for saving and
> loading...
>
> mmalc


I think, the easiest way is to use a document based application. Then
you only have to do a few things.
In MyDocument.nib create an outlet for File's Owner named let's say
"datenControl".
Control-drag from File's Owner to the NSArrayController and connect
this outlet.
Bind NSArrayController's contentArry to File's Owner, let the
Controller Key empty and into Model Key Path enter a name, let's say
"daten".
in MyDocument.h declare

NSMutableArray *daten;
id datenControl;

In MyDocument,m you have only to enter 2 lines (those in {}

- (NSData *)dataRepresentationOfType:(NSString *)aType
{
return [NSKeyedArchiver archivedDataWithRootObject:daten];
}

- (BOOL)loadDataRepresentation:(NSData *)data ofType:(NSString *)aType
{
daten = [NSKeyedUnarchiver unarchiveObjectWithData:data];
return YES;
}

If you want to allow only one window, just disable or delete the
new-menu-item

Cheers
Peter

> _______________________________________________
> 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.
_______________________________________________
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.


  • Follow-Ups:
    • Re: NSArrayController and bindings
      • From: mmalcolm crawford <email@hidden>
References: 
 >NSArrayController and bindings (From: Rob Borsuk <email@hidden>)
 >Re: NSArrayController and bindings (From: mmalcolm crawford <email@hidden>)

  • Prev by Date: Re: NSArrayController and bindings
  • Next by Date: Re: NSArrayController and bindings
  • Previous by thread: [Solved]- Re: NSArrayController and bindings
  • Next by thread: Re: NSArrayController and bindings
  • Index(es):
    • Date
    • Thread