Re: Colored Pattern example problems
Re: Colored Pattern example problems
- Subject: Re: Colored Pattern example problems
- From: FF <email@hidden>
- Date: Thu, 23 Dec 2010 16:09:13 -0500
Thanks to all who answered and Merry Xmas,
with few in line comments.
Jack.
On 2010-12-23, at 12:56 PM, David Duncan wrote:
> On Dec 23, 2010, at 5:58 AM, FF wrote:
>
>> I copied this example from Apple docs.
>
> Generally the examples are there to show you how to use an API, not necessarily to be complete standalone code. You shouldn't necessarily expect doc examples to compile without doing extra work or cross referencing with another example.
I thought, naively, that examples and tutorials in the docs are also aimed at beginners and showing them working examples, which compile without hiccups, is the best way to speed up the learning process.
>> width, height; //Error: unused variables
>
> I would expect that this is obvious :). Also this isn't an error, its a warning (unless you have warnings are errors turned on).
Yes, I can discern warnings from errors, but referred to all 3 as errors for brevity of the problem description.
>
>> static const CGPatternCallbacks callbacks = { 0, &MyDrawPattern, NULL }; //Error: MyDrawPattern undeclared
>
> You need to define the pattern drawing function. This is show in another code example, but for your own purposes you would need to define your own.
>
>> CGContextSetFillPattern (myContext, pattern, &alpha); //Error: arg 3 from incompatible pointer
>
> This is an error in the example, as it declares alpha as a 'float' but the parameter is a CGFloat. This would only come up on 64-bit, where CGFloat is a double, but thats the default configuration now so no surprise you hit it. Looking at the prototype for CGContextSetFillPattern (either in the docs or in the header) would explain what is wrong here however.
Looks like even A. Hillegass can't update his books fast enough to keep up with all the changes : - /
> If your new to CG, then I would recommend you start with the drawing functions, as patterns are relatively advanced and are based upon those functions.
> --
> David Duncan
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden