在 .m 文件的@interface 中初始化的 CGPoint 变量不能有值
CGPoint variable initialized in @interface of .m file can't have value
我在使用 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);
我在使用 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);