objective c - Trying to get the CGColor value from a property causes crash -


I am trying to set such property -

- difference:

< Previous> @property (write, assign, write) CGColorRef Other BallColor;

- Some method:

  CGColorRef ball color = [UIColor colorWithRed: 255.0 / 256.0 green: 165.0 / 256.0 blue: 23 9.0 / 256.0 alpha: 1.0 ] .CGColor; [Self setOffball collar: bowler];  

As soon as I try to reach it crashing value -

- Some other method (draw in this case):

< Pre> CGContextSetFillColorWithColor (Reference, Other Balcon);

But if I do "some method" -

  CGColorRef ball collar = [UIColor blueColor] .CGColor;  

... all this works fine, can someone tell me what's going on?

Many thanks (PS, new enough for Objective-C, though not normally programming)

You have to keep your CGColor back, your [UIColor color] ... creates an automatically released example, therefore, when it goes out of the scope (Iteroaleleged I mean), then This CGColor is also issued.

If you are in this case, then I recommend you use UIColor instead of CGColorRef.


Comments