App crashes when converting Array to Data
When I convert NSArray to NSData with this code:
NSData *data = [NSData dataWithData:folderOpened.arrayOfItems];
NSMutableArray *newObjects = [[NSMutableArray
alloc]initWithArray:[NSKeyedUnarchiver unarchiveObjectWithData:data]];
if (!newObjects) {
newObjects = [[NSMutableArray alloc]init];
}
[newObjects addObject:subfolders];
NSArray *speacilArray = [[NSArray alloc]initWithArray:newObjects];
NSData *finalData = [NSKeyedArchiver
archivedDataWithRootObject:speacilArray];
the app crashes with this message:
-[NSKeyedUnarchiver initForReadingWithData:]: data is empty; did you
forget to send -finishEncoding to the NSKeyedArchiver?
Anyone know why?
No comments:
Post a Comment