我在NSLog/NSAssert等调用中有相当数量的字符串格式说明符,它们分别使用%d和%u使用NSInteger (= int on 32bit)和NSUInteger (= unsigned int on 32bit)类型.
将应用程序转换为64位时,会发出警告(当然),正如%ld %lu现在成为的类型long和unsigned long类型所预期的那样.
简单地转换格式说明符当然会在32位构建中引入反向警告.
因此,我认为唯一可以免于警告的解决方案是使用64位说明符,并在34位值的类型中转换为34位值,并在32位构建中给出警告.
但我想知道是否有专门针对NSInteger和NSUInteger类型的格式说明符可以在没有强制转换的情况下在两种架构上工作?
我在我的项目中使用一个名为SKSTableView的整洁的表视图控制器,它允许每个表行具有多个子行.这段代码在32位模式下运行完美,但是当我在iPhone 5S或4英寸64位模式的模拟器中运行时,当你点击一行来获取子行时它会崩溃.我对64位和32位iOS系统的差异一无所知.我很想知道这里发生了什么.
您会注意到*SubRowObjectKey设置为void-我得到的错误是:
 EXC_BAD_ACCESS_(code = EXC_I386_GPFLT)
这是一个一般保护错误,试图访问不存在的东西(?)
当它崩溃Xcode突出显示这行代码时__CODE__:
#pragma mark - NSIndexPath (SKSTableView)
static void *SubRowObjectKey;
@implementation NSIndexPath (SKSTableView)
@dynamic subRow;
- (NSInteger)subRow
{
    id subRowObj = objc_getAssociatedObject(self, SubRowObjectKey);
    return [subRowObj integerValue];
}
- (void)setSubRow:(NSInteger)subRow
{
    if (IsEmpty(@(subRow))) {
        return;
    }
    id subRowObj = @(subRow);
    objc_setAssociatedObject(self, SubRowObjectKey, subRowObj, OBJC_ASSOCIATION_ASSIGN);
}
+ (NSIndexPath *)indexPathForSubRow:(NSInteger)subrow inRow:(NSInteger)row inSection:(NSInteger)section
{
    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:section];
    indexPath.subRow = subrow;   
    return indexPath;
}
Run Code Online (Sandbox Code Playgroud)

例如,
CABasicAnimation *rotate = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
[rotate setToValue:@(M_PI)];
[rotate setDuration:0.1f];            
[[aView layer] addAnimation:rotate forKey:@"myRotationAnimation"];
在哪里M_PI定义为宏math.h,
#define M_PI  3.14159265358979323846264338327950288   /* pi */