I have a class instance which is basically unstable array from any other object in my own class It needs to be constantly stored in the data but I'm having trouble, I tried to archive using methods
- (zero) archives Favorites (Singleton * Singleton = [Singleton Shared Singlington]; NSLog ("Collection" @); GameDatabase * Favorites Toarekriv = Singleton. Favorite; [NSKeyedArchiver archiveRootObject: favoritesToArchive toFile: [own archives]];} - (NSString *) Sngrhpath {NSString * docDir = [NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex: 0]; return [docDir stringByAppendingPathComponent: @ "Favorite .dat"];} I call again in my View Controller
[ViewController Collection Preference]; "App location enters the background" in my app representative
Basically I have a collection of my own class (game database) in the collection I am trying to store Rann. When this archive is thrown me an exception:
Edit: OK, so I'm trying to apply in my two classes now: GameDatabase.m
- (zero) encoded coder: (encoder *) encoder {[encoder encoded object: games fork: @ "games"]; } - (id) initWithCoder: (NSCoder *) decoder {if (self = [super init]) {games = [decoder DecodeObjectForKey: @ "games"]; } Healthy return; } GameRecord.m
- (id) initWithCoder: (NSCoder *) decoder {if (self = [super init]) {self.name = [Decoder decodeObjectForKey: @ "name"]; Self.gameRules = [DecoderObjectForKey: @ "Game Rule"]; Self. Player = [decoder decoustforky: @ "player"]; Self.gameType = [Decoder DecodeIfForKey: @ "GameType"]; Self.drinkType = [Decoder decodeIntForKey: @ "DrinkType"]; } Healthy return; } - (zero) encoded coder: (Encoder *) encoder {[Encoder encoded object: name for self: @ "name"]; [Encoder encoded object: self.gameRules forKey: @ "GameRules"]; [Encoder encoded: self. For the player: @ "player"]; [Encoder encoded: Type the type for yourself: @ "GameType"]; [Encoder encoded: self. For Drink Type: @ "Drinktep"]; }
You are on the right track, but you should have your own game database class NSCoding protocol Apply Just Add Two Methods
Comments
Post a Comment