Create NSArray from persistent storage
Create NSArray from persistent storage
- Subject: Create NSArray from persistent storage
- From: Ivan Myrvold <email@hidden>
- Date: Mon, 18 Jun 2001 08:20:06 +0400
I am still struggling with my loadDataRepresentation:ofType: method in
my document based application.
I have made a file with this property list structure:
<plist version="0.9">
<array>
<dict>
<key>Start</key>
<string>04:58:11</string>
<key>End</key>
<string>04:58:38</string>
<key>CountryId</key>
<string>97</string>
</dict>
<dict>
<key>Start</key>
<string>04:58:11</string>
<key>End</key>
<string>04:58:38</string>
<key>CountryId</key>
<string>97</string>
</dict>
</array>
</plist>
I have these two method implementations:
- (BOOL)loadDataRepresentation:(NSData *)data ofType:(NSString *)aType
{
if ([aType isEqualToString:myDocumentType]) {
[self restoreFromStorage:data];
return YES;
} else {
return NO;
}
}
- (void)restoreFromStorage:(NSData *)data {
NSArray *theArray;
theArray=[NSArray arrayWithObject:data];
NSLog(@"theArray size: %d", [theArray count]);
[self setDataArray:theArray];
}
The strange thing here is that NSLog always says that I have an array of
size 1, even if I have several entries (here I showed two). What
should I do, to get the array correctly populated (with 1 NSDictionary
instance in each element?
Ivan