Separate names with a comma.
Discussion in 'iOS Programming' started by guydor, Jun 8, 2010.
If I understand your question correctly (you can't "inheritance" from anything: that does not make grammatical sense) then you can't. There is no way to subclass two super-classes (in Objective-C).
On a more general note this does not make architectural sense. One is a view, the other is a controller. They should not be the same object anyway.
Thanks for your reply, I have another question:
How can I inheritance the UIWebView url into another UIViewController?
I cannot understand what you want to do. The word inheritance simply can't be used in that way. Please re-formulate your question so that it makes sense.
First, thanks for your patience
My question is:
I have an UIWebView in UIViewController class A.
I create a string wich gets the UIWebView url;
I want to use this string in UIViewController class B;
How can I do this?
You have classes or instances? I assume instances. Your UIViewController instance A should pass the value to instance B. I suggest you implement a method in B that allows for this.
Can you give me an example please?
How do I do it?
I just told you. If you mean "can you write my code for me?" then the answer is no. Copy and pasting my code is not programming. You need to write the code yourself.
I appreciate your honesty
But what I meant is:
How do I implement it?
What does it mean?
Without being unkind if you don't understand how to implement a method in one class and call that method on an instance then you need to stop programming right now, go back a few steps and learn the language. Once you've done that study the documents on designing an application correctly. Then you can design the classes you need for the application you want. Finally you can write some code.
I honestly can't help you more than that: basic understanding must come first.
Here's what I think you're asking:
1. I have class Blarf (with files Blarf.m and Blarf.h).
2. Somewhere I create an instance Blarf *myBlarfA.
3. I want myBlarfA to create a myBlarfB with a URL that myBlarfA knows.
Create an instance variable NSURL *myURL in class Blarf.
Use @property or write your own setters and getters.
In step 3 above, either:
myBlarfB.myURL = the special URL;
[myBlarfB setMyURL] = the special URL;
To confuse things more, if you don't have a myBlarfB, maybe you want:
[self setMyURL] = the special URL;
But the other guy's suggestion is probably better - if you're new to Cocoa, Objective-C and OOP, then grab a book and work through a couple of chapters.