Question

I have an app that currently supports armv7, armv7s and arm64. Having started the project before the A7 64 bit chip was released everything was designed with the sole intention of supporting only the 32 bit architecture.

I'm getting conflicting return type warning when attempting to build to a 64bit device. For example,

- (float) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 45.0;
}

Conflicting return type in implementation of tableView:heightForRowAtIndexPath:' : 'CGFloat' (aka 'double') vs 'float'

If I do switch the return type to double for 64 bit support I get the same inverse situation when attempting to build for a 32 bit system saying it wants a float not a double.

How do I correctly support both of these? Should I simply convert to 64bit as described in this article and ignore the warnings thrown by the compiler when I try and build for a 32bit?

Was it helpful?

Solution

Copy the method signature from the protocol:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

CGFloat is defined appropriately to handle the architecture that the app is running on

OTHER TIPS

You need to use the CGFloat type, which is defined as follows:

#if defined(__LP64__) && __LP64__
# define CGFLOAT_TYPE double
# define CGFLOAT_IS_DOUBLE 1
# define CGFLOAT_MIN DBL_MIN
# define CGFLOAT_MAX DBL_MAX
#else
# define CGFLOAT_TYPE float
# define CGFLOAT_IS_DOUBLE 0
# define CGFLOAT_MIN FLT_MIN
# define CGFLOAT_MAX FLT_MAX
#endif

CGFloat is macro that subs out float on 32 bit platforms and double on 64 bit platforms.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top