小编Joe*_*Joe的帖子

在switch块中实例化新对象 - 为什么会失败?

为什么

switch ([document currentTool]) {
    case DrawLine:
        NSBezierPath * testPath = [[NSBezierPath alloc]init];
        //...rest of code that uses testPath....
Run Code Online (Sandbox Code Playgroud)

造成

error:syntax error before "*" token

对于testPath?

objective-c

4
推荐指数
1
解决办法
1244
查看次数

convertPoint:

我正在学习Objective-C和Cocoa(在时间允许时适合开始)所以请保持温和.

示例应用程序具有以下行:

NSPoint down = [mouseEvent locationInWindow];
//...some other stuff
NSPoint p = [self convertPoint:down fromView:nil]; 
Run Code Online (Sandbox Code Playgroud)

然后继续使用p进行拖放操作(使用pasteBoard).但是,我没有得到的是这一切都在一个视图中,为什么不只是使用down,为什么一个convertPoint:?还是我错过了一些基本的东西?

谢谢!

objective-c

2
推荐指数
1
解决办法
3691
查看次数

标签 统计

objective-c ×2