1

I use the following code to dynamically resize labels:

CGRect frame = self.myLabel2.frame;
frame.origin.y = self.myLabel1.frame.origin.y + self.myLabel1.frame.size.height + 10;
frame.size = LABEL_SIZE(self.myLabel2);
self.myLabel2.frame = frame;

Where LABEL_SIZE is a macro defined as :

#define LABEL_SIZE(label) CGSizeMake(280, [label sizeThatFits:CGSizeMake(280, FLT_MAX)].height);

The code works absolutely fine when run on simulator (32-bit). The problem arises when running on simulator (64-bit). XCode shows it not as a warning, but as an error, due to which, it will not even compile.

I do not understand, am I missing something?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
n00bProgrammer
  • 4,261
  • 3
  • 32
  • 60

2 Answers2

0

You forgot to include float.h

#include <float.h>
float a = FLT_MAX;
Bram
  • 7,440
  • 3
  • 52
  • 94
-2

Try to use CGFLOAT_MAX instead of FLT_MAX as show below

#define LABEL_SIZE(label) CGSizeMake((CGFloat)280, [label sizeThatFits:CGSizeMake((CGFloat)280, (CGFLOAT_MAX))].height);
Rustam Gasanov
  • 15,290
  • 8
  • 59
  • 72
Sethu
  • 71
  • 1
  • 3