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

Re: Create NSArray from persistent storage


  • Subject: Re: Create NSArray from persistent storage
  • From: Scott Anguish <email@hidden>
  • Date: Mon, 18 Jun 2001 01:52:05 -0400

Actually, your array is exactly what you'd expect.. you're adding a single NSData item to the array

- (void)restoreFromStorage:(NSData *)data {
NSArray *theArray;
theArray=[NSArray arrayWithObject:data];
NSLog(@"theArray size: %d", [theArray count]);
[self setDataArray:theArray];
}


What you want to do is either this (for your restoreFromStorage)

- (void)restoreFromStorage:(NSData *)data {
NSString *tempString;
NSArray *theArray;

tempString=[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
theArray=[tempString propertyList];
[self setDataArray:theArray];
}


or, you could instead use the file handling method of dealing with Data in the NSDocument classes


- (BOOL)readFromFile:(NSString *)fileName ofType:(NSString *)type
{
NSArray *theArray;

theArray=[NSArray arrayWithContentsOfFile:fileName];
[self setDataArray:theArray];
return (theArray !=nil);
}


References: 
 >Create NSArray from persistent storage (From: Ivan Myrvold <email@hidden>)

  • Prev by Date: Re: Create NSArray from persistent storage
  • Next by Date: Visualizing Cocoa
  • Previous by thread: Re: Create NSArray from persistent storage
  • Next by thread: Re: Create NSArray from persistent storage
  • Index(es):
    • Date
    • Thread