我试图从一个功能点基础结构,称为:我不能从一个函数得到的NSArray作为返回值
-(NSArray *) calcRose : (float) theta
{
//first calculate x and y
//we need to get width and height of uiscreen
//myPoint[0] = [UIScreen mainScreen].applicationFrame.size.width;
NSMutableArray *Points = [[NSMutableArray alloc ] arrayWithCapacity:2];
float angle = [self radians:theta];
float side = cos(n * angle);
int cWidth = 320;
int cHeight = 240;
float width = cWidth * side * sin(angle)/2 + cWidth /2;
float height = cHeight * side * cos(angle)/2 + cHeight /2;
[Points addObject:[NSNumber numberWithFloat:cWidth]];
[Points addObject:[NSNumber numberWithFloat:cHeight]];
NSArray *myarr = [[[NSArray alloc] initWithArray:Points ]autorelease ];
return myarr;
}
我用下面的代码从功能检索数据:
NSArray *tt = [[ NSArray alloc] initWithArray:[self calcRose:3] ];
但是每次我编译程序都会给我一些错误。
我该如何解决这个问题?
什么编译错误你见过? – 0x8badf00d
2011-11-07 11:25:18.061 myFirstGraphicProgram [40922:40b] 0.174533 2011-11-07 11:25:18.062 myFirstGraphicProgram [40922:40b] - [__ NSPlaceholderArray arrayWithCapacity:]:发送到实例0x4e02a90的无法识别的选择器 2011 -11-07 11:25:18.063 myFirstGraphicProgram [40922:40b] ***因未捕获异常'NSInvalidArgumentException'而终止应用程序,原因:' - [__ NSPlaceholderArray arrayWithCapacity:]:无法识别的选择程序发送到实例0x4e02a90' ***调用第一次扔栈: ( \t。 ) 抛出'NSException'实例后终止 –
你知道你没有使用宽度和高度,是不是?虽然没有解决你的问题。 – dasdom