ios - How to deal with unarchiver with this situation..? -
I am creating a simple program that can store my object and it can be uninvited after launch.
I have a list.m where the temporary array is stored under the name Favorites list ; it gets in the file through the archive . (Zero) loadList {self.favouritesList - inside the list, I would like the ordinary object favouriteItem then, the problem would be with this code The exception is that I have found this [NSKeyedUnarchiver initForReadingWithData:]: is out of the collection (0x62, 0x70, 0x6c, 0x69, 0x73, 0x74, 0x30, 0x30 ) ' I know that I am incompatible with file which is empty (in fact it is copied from file to bundle, which is also empty). So, how can I avoid it when I still want my app loaded to load the data from the file. When I use the code as the following The easy way to use exception handling is to use. Apple's document is here.
Is said = [[NSKeyedUnarchiver unarchiveObjectWithFile: self.fileName] mutableCopy]; If (self.favouritesList == zero) self.favouritesList = [[NSMutableArray alloc] init]; }
- (zero) loadData {self.URLLists = [NSMutableArray arrayWithContentsOfFile: self.path]; If (self.URLList == zero) {self.URLLists = [[NSMutableArray alloc] init]; }} here , even if the file was empty on self.path, it returns zero and I can only say that it has become zero , I will provide new one for the first time, but with the NSkeyedUnarchiver it works a bit differently .. can you tell how this is different and how I am saved from this error Can I ... Thank you
@try {self.favouritesList = [[NSKeyedUnarchiver unarchiveObjectWithFile: self.fileName] mutableCopy]; } @chich (NSE expansion * e) {self.favouritesList = [[NSMUTABARARRAR] INIT]; // Essentially add more code}
Comments
Post a Comment