Thursday, May 2, 2013

NSKeyedArchiver encodeDouble example ios

encodeDouble :forKey:

Encodes a given double value and associates it with a given key.
- (void)encodeDouble:(double)realv forKey:(NSString *)key
Parameters of [NSKeyedArchiver encodeDouble]
The value to encode.
The key with which to associate realv. This value must not be nil.
    Example of [NSKeyedArchiver encodeDouble]

    - (void)encodeWithCoder:(NSCoder *)aCoder {
        [aCoder encodeObject:_address forKey:@"address"];
        NSLog(@"ENCODING coordLatitude %f coordLongitude %f ", _coordinate.latitude, _coordinate.longitude);
        [aCoder encodeDouble:_coordinate.longitude forKey:@"coordinate.longitude"];
        [aCoder encodeDouble:_coordinate.latitude forKey:@"coordinate.latitude"];
        [aCoder encodeObject:title forKey:@"title"];
    Example of [NSKeyedArchiver encodeDouble]
    -(void)encodeWithCoder:(NSCoder *)encoder
        [encoder encodeInt:ID forKey:@"ID"];
        [encoder encodeDouble:GeoLat forKey:@"GeoLat"];
        [encoder encodeDouble:GeoLong forKey:@"GeoLong"];
        NSLog(@"Name in encode: %@", Name); //WORKS!
        [encoder encodeObject:Name forKey:@"Name"];
        [encoder encodeObject:Phone forKey:@"Phone"];
        [encoder encodeObject:Address forKey:@"Address"];