Re: NSArray usage question.
Re: NSArray usage question.
- Subject: Re: NSArray usage question.
- From: Thomas Lachand-Robert <email@hidden>
- Date: Fri, 6 May 2005 23:19:13 +0200
Le 6 mai 05 à 21:24, Brian O'Brien a écrit :
Is this the correct way to build and use an NSArray?
NSPoint ptArray[plist->getNPolys()];
CPoint p;
for (i=0; i < plist->getNPolys(); ++i)
{
p = plist->getPoint(i);
ptArray[i].x = p.x;
ptArray[i].y = p.y;
}
NSArray *pts = [NSArray arrayWithObjects:ptArray count:i];
NSBezierPath *path = [NSBezierPath bezierPath];
[path appendBezierPathWithPoints:pts count:i];
No. You are declaring ptArray as a C-array of NSPoint: these are not
objects, but simple structs. So you cannot use arrayWithObjects:
which expects objects as arguments.
Also since the signature of appendBezierPathWithPoints is
- (void)appendBezierPathWithPoints:(NSPoint *)points count:(int)count
you can pass directly ptArray here. So the NSArray has no purpose.
The compiler should have warned you for these inconsistencies. It is
important to always read carefully compiler's warnings.
Hope this helps,
Thomas Lachand-Robert
********************** email@hidden
<< Et le chemin est long du projet à la chose. >> Molière, Tartuffe.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden