开发者

How do I return CGpoint function?

If i have开发者_如何学Python this function:

 -(CGPoint)limitPosition:(CGPoint)position {
          //code here

              return position;
      }

how do I return it to a variable?

This:

CGPoint a;
CGPoint b;

a = [self limitPosition: b]; 

Doesnt work.


Without a clearer description of what you mean by "doesn't work", and probably what's going on where you have //code here, it's hard to say.

Basically, you can pass a CGPoint to and from a function or method with the syntax as you have it. It'll be passed by value, so that any changes to position inside the function will not be reflected in the variable passed as argument (b), but should be copied back in the return value (to a).

In the code fragment shown, you don't initialise a or b, so they may contain garbage. And obviously the method body isn't doing much. But otherwise it looks kosher, so the problem is probably elsewhere.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜