I tried to convert NSString to NSDate as the instruction: NSString to NSdate
My snippet does not work, maybe the source NSString extracts incorrect from ABPerson, with kABBirthdayProperty. It gets error with reason:
-[__NSTaggedDate bytes]: unrecognized selector sent to instance 0xc1c3a7619800000d
This is the snippet:
-(void) abRead: (ABPerson*) myRecord
{ if ([myRecord valueForProperty:kABBirthdayProperty] != nil)
{ NSDateFormatter* myBirthday = [[NSDateFormatter alloc] init];
[myBirthday setDateFormat:@"YYYY-DD-MM HH:MM:SS"];
NSDate* birthDay = [myBirthday dateFromString:[myRecord valueForProperty:kABBirthdayProperty]];
}
I guess that the NSString got from kABBirthdayProperty have some special format or some thing. I checked:
NSLog(@"birthday: %@", [myRecord valueForProperty:kABBirthdayProperty]);
it print out as NSString should be:
birthday :1980-02-08 05:00:00 +0000
Do I need any conversion from ABPerson:kABProperty to NSString correctly?
sorry for my bad English.