Thursday, May 2, 2013

NSKeyedArchiver encodeInt example ios

encodeInt :forKey:

Encodes a given int value and associates it with a given key.
- (void)encodeInt:(int)intv forKey:(NSString *)key
Parameters of [NSKeyedArchiver encodeInt]
The value to encode.
The key with which to associate intv. This value must not be nil.
Example of [NSKeyedArchiver encodeInt]
- (void)encodeWithCoder:(NSCoder *)coder {
    [coder encodeObject:whitePlayer forKey:@"whitePlayer"];
    [coder encodeObject:blackPlayer forKey:@"blackPlayer"];
    [coder encodeInt:playerOnTop forKey:@"playerOnTop"];
    [coder encodeInt:turn forKey:@"turn"];
    [coder encodeObject:board forKey:@"board"];
Example of [NSKeyedArchiver encodeInt]
-(void)encodeWithCoder:(NSCoder *)aCoder {

 [aCoder encodeInt:x forKey:@"x"];
 [aCoder encodeInt:y forKey:@"y"];
 [aCoder encodeInt:location forKey:@"location"];
 [aCoder encodeInt:quarter forKey:@"quarter"];
 [aCoder encodeBool:made forKey:@"made"];