How to know the size of a dash pattern in a NSBezierPath ?
13/01/04 10:05
When using - (void)getLineDash:(float *)pattern count:(int *)count phase:(float *)phase how do I know the size of the pattern buffer to pass since I don't know yet the value of count ?
You need to call - (void)getLineDash:(float *)pattern count:(int *)count phase:(float *)phase twice.
First time, just pass nil for pattern and initialize count to -1 (for compatibility with GNUstep):
float *myPattern = nil ;
int myCount = -1 ;
[myPath getLineDash:nil count:&myCount phase:&myPhase];
if (count > 0) {
myPattern = malloc( count * sizeof(float) ) ;
[myPath getLineDash: myPattern count:&myCount phase:&myPhase];
}
First time, just pass nil for pattern and initialize count to -1 (for compatibility with GNUstep):
float *myPattern = nil ;
int myCount = -1 ;
[myPath getLineDash:nil count:&myCount phase:&myPhase];
if (count > 0) {
myPattern = malloc( count * sizeof(float) ) ;
[myPath getLineDash: myPattern count:&myCount phase:&myPhase];
}