1

In my CGFloat wrapper Im getting an error Returning CGFloat (aka Double) from a function result type CGfloat aka double take the address with &

+(CGFloat*)pointData;

//

+(CGFloat *)pointData{


    NSInteger savedInt = [[NSUserDefaults standardUserDefaults] integerForKey:@"savedPointForText"];
    CGFloat textPoint = (CGFloat)savedInt;

    if(textPoint <1) {

        textPoint = 18.0;
    }


    return textPoint;
}

If I do return &textPoint; I get a warning that address of stack memory with local variable "textpoint" returned

JSA986
  • 5,870
  • 9
  • 45
  • 91

2 Answers2

1

In this case, you can just return the CGFloat itself, if you change the signature to:

+ (CGFloat)pointData {

You need CGFloat * in case you don't want to return the variable (perhaps because you actually need to manipulate more than one variable):

+ (void)changePointData:(CGFloat *)pointData {
    NSInteger savedInt = [[NSUserDefaults standardUserDefaults] integerForKey:@"savedPointForText"];
    *pointData = (CGFloat)savedInt;

    if (*pointData < 1) {    
        *pointData = 18.0;
    }
}
Glorfindel
  • 21,988
  • 13
  • 81
  • 109
1

You can try

+(CGFloat)pointData{

    //Your code
}

Hope it helps.

Pradumna Patil
  • 2,180
  • 3
  • 17
  • 46