私は手渡され、(NSInteger) pageIndex
それをページに印刷する必要があります
void CGContextShowTextAtPoint (
CGContextRef c,
CGFloat x,
CGFloat y,
const char *string,
size_t length
);
const char *string
その文字列の長さを忘れないようにするにはどうすればよいですか
最初に整数を文字列に変換してから変換するという厄介なトリックに行き着く傾向がありますcStringUsingEncoding:NSMacOSRomanStringEncoding
が、それは最もエレガントな方法ではありません
完全を期すために、ここにコードがあります
const char *pageIndexString = [[NSString stringWithFormat:@"%d", pageIndex] cStringUsingEncoding:NSMacOSRomanStringEncoding];
CGContextShowTextAtPoint(CGContextRef, CGFloat x, CGFloat y, pageIndexString, strlen(pageIndexString));