Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 类方法在目标c中不起作用_Objective C_Class_Properties_Methods_Instance - Fatal编程技术网

Objective c 类方法在目标c中不起作用

Objective c 类方法在目标c中不起作用,objective-c,class,properties,methods,instance,Objective C,Class,Properties,Methods,Instance,在我的代码中,我有一个名为“ProfileShareViewController”的类,我在其中导入了我创建的另一个名为“OwnProfileData”的类,我还创建了该类的一个实例(class=OwnProfileData)作为“ProfileShareViewController”的属性,并将其合成(实例名为“OwnProfile”) 在另一个名为“EditProfileViewController”的类中,我导入了“ProfileShareViewController”,现在我正在尝试从E

在我的代码中,我有一个名为“ProfileShareViewController”的类,我在其中导入了我创建的另一个名为“OwnProfileData”的类,我还创建了该类的一个实例(class=OwnProfileData)作为“ProfileShareViewController”的属性,并将其合成(实例名为“OwnProfile”)

在另一个名为“EditProfileViewController”的类中,我导入了“ProfileShareViewController”,现在我正在尝试从EditProfileViewController类中的ProfileShareViewController更改OwnProfile对象的属性

因为某种原因,那是行不通的。我试过打字:

[[ProfileShareViewController ownProfile] setName:@"Ido"];
(我试图设置的属性是Name,由于它是在OwnProfileData中合成的,所以我使用的是“setName”)。 这不起作用,我得到警告:“选择器'ownMethod'没有已知的类方法。”

你知道为什么会发生这种情况,以及我如何解决这个问题吗


感谢您的评论!非常感谢您的支持!

您需要
ProfileShareViewController
的实例,因为
ownProfile
是实例属性,而不是类方法。请阅读类和实例之间的区别


还是我误解了smth?

但如果它是iOS应用程序中的视图控制器类,那么to的实例是什么?还是我只是创建了一个随机的实例?