在iOS和OSX上使用unsigned int和unsigned long编译NSLog,不会有任何警告

在iOS上NSUInteger是一个unsigned int ,在OSX上它是一个unsigned long unsigned int 。 我怎样才能做一个打印语句像

  NSLog(@"Array has %d elements.",[array count]); 

在两个平台上编译没有警告? 我当然可以使用#ifdef #else #endif结构,但会添加4行代码。 我也可以将返回值转换为unsigned int。 有一个更短的解决scheme?

如何铸造到两个更大的?

 NSLog(@"Array has %ld elements.",(unsigned long)[array count]); 

在iOS中没有任何警告,我认为这是在OSX中没有任何操作。

如何铸造到两个更大的?

 NSLog(@"Array has %ld elements.",(unsigned long)[array count]); No warning in iOS, and I think it's a no-op in OSX.