Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8586699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:22:25+00:00 2026-06-11T22:22:25+00:00

I get confused sometimes when working with CG elements, and have the following scenario

  • 0

I get confused sometimes when working with CG elements, and have the following scenario that seems simple but is giving me trouble.

I have a CGColorRef property called fillColor, for which I manually define the setter method as follows:

@property(nonatomic) CGColorRef fillColor;

- (void) setFillColor:(CGColorRef)fillColor
{
    CGColorRetain(fillColor); 
    CGColorRelease(_fillColor); 
    _fillColor = fillColor;
}

After I _fillColor to some value, I store it in an array as follows:

_fillColors = [[NSArray alloc] initWithObjects:(id)_fillColor, nil];

I’d like it so that when change self.fillColor, I’d like it for the value in the array to change also. I could obviously make a pointer, ie CGColorRef *fillColor, but in doing that how would I manage the memory (ie release, retain it) and how would my setter method change? This is really confusing me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T22:22:27+00:00Added an answer on June 11, 2026 at 10:22 pm

    NSArray copies its objects. NSArray will receive a copy of the pointer you pass in. That means you get a copy of a pointer to a CGColor struct (Yes, CGColorRef is already a pointer). So changing either one will never have any effect on the other. Storing a pointer to the CGColorRef seems to be the only way, other than using NSPointerArray (which is only iOS 6+).

    EDIT: The end result was making a class that contained all the information in one place (path, color, etc) and storing a pointer to that instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a very simple question for compiler guys, but I always get confused
I have the following line of xml that I'm trying transform using XSLT but
Sometimes I get confused about when not releasing an object. I have: NSTimer *timer2;
I have been using MVP for a while .Sometimes I get confused what actions
I am trying to write this loop in Python but get confused. Basically I
confused - given a track uri, I can get one album but possibly more
RegEx has always confused me. I have a string like this: IDE\DiskDJ205GA20_____________________________A3VS____\5&1003ca0&0&0.0.0 Or Sometimes
I have a very subtle bug that I'm having trouble identifying. Background: We have
Why does VisualC++ (2008) get confused 'C2666: 2 overloads have similar conversions' when I
I'm new to PHP and this question seems stupid. But I'm really confused with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.