NSDate *now = [NSDate date];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy"];
NSString *stringFromDate = [formatter stringFromDate:now];
CGContextShowTextAtPoint(context, 50, 50, stringFromDate, 5);
I am not getting the exact date? also getting warning while compiling
warning: passing argument 4 of ‘CGContextShowTextAtPoint’ from incompatible pointer type
What is the value of
stringFromDate? What are you expecting?If you look at the docs for
CGContextShowTextAtPoint, you’ll see that the fourth parameter needs to be achar*, not anNSString*.You have:
You want: