I have the following property:
@property (nonatomic) CGColorRef *strokeColor;
At a certain point in my program, I set it to nil. Then later on in my program I check to see if it's nil:
CGColorRef strokeColor = (*graphicPath.strokeColor != nil) ? CGColorRetain(*graphicPath.strokeColor) : nil;
I'm getting a bad access at this line. I've also tried using NULL and still no dice. It works when there is something stored in it and it's not nil / NULL.
How can I get this to work?
卸下*
您则strokeColor的定义(这已经是一个指针,因为它是一个CGColorRef
),并从graphicPath,它可能会解决您的问题。
Check my comment above:
Whether I don't understand what you're trying to do or your syntax is definitely wrong. Why are you using indirection (*) in the comparison? Remember CGColorRef is already a reference, you don't need to use it as a pointer!
And accept this an answer if helped you.
Had to change
(*graphicPath.strokeColor != nil)
to
(graphicPath.strokeColor != nil)
(got rid of the asterisk).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.