• 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
Create NSArray from persistent storage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Create NSArray from persistent storage
      • From: Gideon Tearle <email@hidden>
    • Re: Create NSArray from persistent storage
      • From: Scott Anguish <email@hidden>
    • Re: Create NSArray from persistent storage
      • From: David P Henderson <email@hidden>
  • Prev by Date: Re: CoreFoundation <==> Foundation?
  • Next by Date: Re: Create NSArray from persistent storage
  • Previous by thread: Re: Memory Management and DO
  • Next by thread: Re: Create NSArray from persistent storage
  • Index(es):
    • Date
    • Thread