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 8337993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:27:33+00:00 2026-06-09T04:27:33+00:00

Trying to create a property, so I can set CGfloat array values on an

  • 0

Trying to create a property, so I can set CGfloat array values on an instance of a class. Having a hard time figuring out how to do it. The CGFloat needs to have “size” [2] variable and numeric components like below:

CGFloat locations[2] = {1.0, 0.0};

Here is how it looks in the class itself (this works), before I created the property in an attempt to set these values from an instance (this creates a gradient BTW via drawRect in a UIView sunclass):

CGContextRef context = UIGraphicsGetCurrentContext();
CGColorSpaceRef myColorspace=CGColorSpaceCreateDeviceRGB();
CGFloat locations[2] = {1.0, 0.0};
CGFloat components[8] = { 1.0, 0.0, 0.0, 1.0,  0.5, 0.25, 1.0, 1.0 };
CGGradientRef myGradient = CGGradientCreateWithColorComponents(myColorspace, components,locations, num_locations);
CGContextDrawLinearGradient (context, myGradient, myStartPoint, myEndPoint, 0);

I tried creating a property like below in the .h

@property (nonatomic, assign) CGFloat locations;

and in the .m

@synthesize locations;

But I cant figure out how to properly set the values for the [size] and the components from the instance. Also I get errors when I set up the property: ERROR: “Passing ‘CGFloat’ (aka ‘float’) to parameter of incompatible type ‘const CGFloat *’ (aka ‘const float *’); take the address with &”

you can get the project here is you feel like taking a look tinyurl.com/cmgy482 Any help much appreciated.

  • 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-09T04:27:34+00:00Added an answer on June 9, 2026 at 4:27 am

    From another answer found here: “C arrays are not one of the supported data types for properties”. I think that was my issue. The solution I used, is to make the property an NSMutableArray and to convert the values to a CGFloat.

    .h

    @property (nonatomic, retain) NSMutableArray *locations;
    

    .m

    CGFloat locationsFloat[[locations count]];
    
        for (int i = 0; i < [locations count]; i++) {
            NSNumber *number = [locations objectAtIndex:i];
            locationsFloat[i] = [number floatValue];        
        } 
    

    viewController

    - (void)viewDidLoad
    {
        NSMutableArray *arrayPoints = [[NSMutableArray alloc]init];    
        [arrayPoints addObject:[NSNumber numberWithFloat:1.0]];
        [arrayPoints addObject:[NSNumber numberWithFloat:0.0]];
    
        [myInstance setLocations:arrayPoints];
    
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a class with a single property which can be
I am trying to create a SortedList of property names and values for any
I'm trying to create a point class which defines a property called coordinate. However,
I'm trying to create a simple extensible class in javascript but when setting property
I'm trying to create a class that inherits from ListBox and adding the property
I'm trying to create a custom property for my web part, but can't get
I'm trying to create delegates to access any Property Get & Set methods. I
I'm trying to create an abstract class that defines a property with a getter.
I trying create iis7 web application by msbuild community tasks and set property Enabled
Using a PrivateObject , I'm trying to create an instance of the ItemChange class

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.