iphone 将值从子类传递给超类
你好,我想在不使用对象的情况下从子类向超类传递一个字符串值。任何人都可以帮忙吗?我知道它与[self superView]
有关。请帮忙
class c1 { string s1 -(void) m1 { } } class c2 { // Here I want to call m1 and also pass values to s1 // without creating an object of the class c1 }
Hi, I want to pass a string value to the superclass from the subclass without using object. Can anyone please help. I know it has something to do with [self superView]
. please help
class c1 { string s1 -(void) m1 { } } class c2 { // Here I want to call m1 and also pass values to s1 // without creating an object of the class c1 }
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
他们与超类通信的关键字是
super
。您可以像这样调用超类上的方法:They keyword to communicate with the superclass is
super
. You can invoke methods on the superclass like this:你的问题需要更具体。
如果您使用的是 Objective-C(iPhone 应用程序的典型编程语言),那么您可以使用:
此调用采用关键字 super,它是对超类的引用,后跟您想要发送给超类的消息(Objective-C 方法)(Objective-C 的“调用方法”方式)。
如果您使用的是 C++(您的示例代码似乎表明了这一点),那么由于多重继承问题,我认为您无法调用超类方法。
You need to be more specific with your question.
If you're using Objective-C (the typical programming language for iPhone apps), then you can use:
This call takes the keyword super, which is a reference to the superclass, followed by the name of the message (an Objective-C method) you want to send to the superclass (Objective-C's way of "calling a method").
If you're using C++ (which your sample code seems to indicate), then I don't think you can call the superclass methods due to multiple inheritance issues.