Objective c 类方法在目标c中不起作用
在我的代码中,我有一个名为“ProfileShareViewController”的类,我在其中导入了我创建的另一个名为“OwnProfileData”的类,我还创建了该类的一个实例(class=OwnProfileData)作为“ProfileShareViewController”的属性,并将其合成(实例名为“OwnProfile”) 在另一个名为“EditProfileViewController”的类中,我导入了“ProfileShareViewController”,现在我正在尝试从EditProfileViewController类中的ProfileShareViewController更改OwnProfile对象的属性 因为某种原因,那是行不通的。我试过打字: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 ownProfile] setName:@"Ido"];
(我试图设置的属性是Name,由于它是在OwnProfileData中合成的,所以我使用的是“setName”)。
这不起作用,我得到警告:“选择器'ownMethod'没有已知的类方法。”
你知道为什么会发生这种情况,以及我如何解决这个问题吗
感谢您的评论!非常感谢您的支持!您需要
ProfileShareViewController
的实例,因为ownProfile
是实例属性,而不是类方法。请阅读类和实例之间的区别
还是我误解了smth?但如果它是iOS应用程序中的视图控制器类,那么to的实例是什么?还是我只是创建了一个随机的实例?