在 .m 文件@interface初始化的 CGPoint 变量不能具有值


我在使用 CGPoint 时

遇到了问题,我在这里也找不到任何答案,所以我提出了这个问题,我希望在 .m 文件周围可以访问 2 个变量,但是当我尝试在 CGPoint 变量中输入值时,它给了我一个"预期表达式"。我是iOS应用程序开发的初学者,所以我真的不知道如何解决这个问题,任何人都可以给我这方面的提示吗?我将不胜感激。这是我正在尝试执行的操作的示例代码

在 .m 文件中:

@interface file()
{
    CGPoint sample1;
    CGPoint sample2;
}
@implementation file
-(void)viewDidLoad(){
   sample1 = {5.0, 8.0};    ->> and this is where I’m getting the “expected expression” error.
   sample2 = {4.0, 2.0};    ->> and this is where I’m getting the “expected expression” error.
 }
sample1 = CGPointMake(5.0, 8.0);
sample2 = CGPointMake(4.0, 2.0);

最新更新