【发布时间】:2010-09-08 21:21:39
【问题描述】:
我正在开发一个 iphone 应用程序,当我编译它时,我收到了一些警告。该应用程序可以正常工作,但删除所有警告可能会很有趣吗?
这是其中之一,我无法理解,主要是因为我是 iPhone SDK 的“菜鸟”,而这个类来自另一个代码(免费代码)。
警告是:
警告:函数“NSAllocateCollectable”的隐式声明 警告:初始化使指针从整数而不进行强制转换
代码是这样的:
double *MatrixAllocateArray( NSUInteger rows, NSUInteger columns )
{
// Allocate an array to hold [rows][columns] matrix values
NSCParameterAssert(rows!=0);
NSCParameterAssert(columns!=0);
__strong double *array = NSAllocateCollectable(SIZEOFARRAY(rows,columns),0); //(WARNINGS APPEAR HERE)
NSCAssert2(array!=NULL,@"falled to allocate %dx%d matrix",rows,columns);
return array;
}
正如你所见,这个函数试图分配一个矩阵,它被另一个函数调用。
double *MatrixAllocateEmptyArray( NSUInteger rows, NSUInteger columns )
{
// Allocate a matrix array and fill it with zeros
__strong double *emptyArray = MatrixAllocateArray(rows,columns);
bzero(emptyArray,SIZEOFARRAY(rows,columns));
return emptyArray;
}
这是由我执行和需要的函数调用的:
- (id)initWithRows:(NSUInteger)rowCount columns:(NSUInteger)colCount
{
// Create an empty matrix
return [self initWithAllocatedArray:MatrixAllocateEmptyArray(rowCount,colCount)
rows:rowCount
columns:colCount];
}
【问题讨论】:
标签: iphone objective-c xcode