Re: NSArrayController
Re: NSArrayController
- Subject: Re: NSArrayController
- From: Mike Ferris <email@hidden>
- Date: Mon, 5 Jul 2004 08:45:08 -0700
In particular, this will work only if all the objects in your array are
property list objects (ie nothing but NSString, NSNumber, NSDate,
NSData, NSArray, and NSDictionary).
Otherwise, you'll need to write a bit more open/save code (for now).
You can look at Sketch for an example of a relatively straight-forward
and general implementation pattern for using property lists as a
document format while still using concrete model classes (ie not
plists... in Sketch's case, SKTGraphic objects) in the running app.
Mike
Begin forwarded message:
>
From: Johan Kool <email@hidden>
>
Date: July 4, 2004 2:57:46 PM PDT
>
To: email@hidden
>
Cc: Matt Jarjoura <email@hidden>
>
Subject: NSArrayController
>
>
Hi Matt,
>
>
Here is some sample code:
>
>
- (BOOL)writeToFile:(NSString *)path ofType:(NSString *)docType
>
{
>
return [[mainArrayController content] writeToFile:path
>
atomically:YES];
>
}
>
>
- (BOOL)readFromFile:(NSString *)path ofType:(NSString *)docType
>
{
>
[mainArrayController setContent:[NSArray
>
arrayWithContentsOfFile:path]];
>
return YES;
>
}
>
>
This of course only works with your own XML files. If you want to
>
parse other XML files, take a look at the documentation for
>
NSXMLParser.
>
>
Hope that helps! Cheers,
>
>
Johan
>
>
Op 4 jul 2004 om 23:43 heeft email@hidden het
>
volgende geschreven:
>
>
> Van: Matt Jarjoura <email@hidden>
>
> Datum: 4 juli 2004 23:42:04 GMT+02:00
>
> Aan: Cocoa Dev <email@hidden>
>
> Onderwerp: NSArrayController
>
>
>
>
>
> Is there an easy way to use NSDocument to parse a file into an
>
> NSArrayController? Do I need to subclass NSArrayController?
>
>
>
> -Matt
>
_______________________________________________
>
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.