This is my code but i can't getting the data
NSData *wrtData = [NSKeyedArchiver archivedDataWithRootObject:my_Array];
This is my code but i can't getting the data
NSData *wrtData = [NSKeyedArchiver archivedDataWithRootObject:my_Array];
If you want to convert a NSArray
to NSData
you should make sure that all objects inside this array conform to NSCoding protocol. Same goes for NSDictionary
.
Use this sample:
NSArray *mapPoints = @[
@{ @"latitude":@"10.010490",
@"longitude":@"76.360779",
@"altitude":@"30.833334",
@"timestamp":@"11:17:23",
@"speed":@"0.00",
@"distance":@"0.00"
},
@{
@"latitude":@"10.010688",
@"longitude":@"76.361378",
@"altitude":@"28.546305",
@"timestamp":@"11:19:26",
@"speed":@"1.614",
@"distance":@"198.525711"
}
];
NSLog(@"Countries array = %@",mapPoints);
NSData *mapPointsData = [NSKeyedArchiver archivedDataWithRootObject:mapPoints];
NSLog(@"countries data=%@",mapPointsData);
NSLog(@"mapPointsData to mapPointsArray = %@",[NSKeyedUnarchiver unarchiveObjectWithData:mapPointsData]);