在iOS上NSUInteger
是unsigned int
,在OSX上是unsigned long
。我怎样才能输出像
NSLog(@"Array has %d elements.",[array count]);
在没有警告的情况下在两个平台上编译?我当然可以使用#ifdef #else #endif
结构,但这将增加4行代码。我也可以将返回值强制转换为unsigned int。有没有更短的解决方案?
如果将其转换为较大的一个呢?
NSLog(@"Array has %ld elements.",(unsigned long)[array count]);
在iOS中没有警告,我认为这在OSX中是一个No -op
如果将其转换为较大的一个呢?
NSLog(@"Array has %ld elements.",(unsigned long)[array count]);
No warning in iOS, and I think it's a no-op in OSX.