x404.co.uk
http://www.x404.co.uk/forum/

Woop! (Also a question about subclassing).
http://www.x404.co.uk/forum/viewtopic.php?f=4&t=14792
Page 1 of 1

Author:  Fogmeister [ Wed Sep 21, 2011 8:32 am ]
Post subject:  Woop! (Also a question about subclassing).

Well I finally got the guy's library of C++ code working last night! (almost).

There was one line of code that I had to comment but he's sent me a fix for it this morning.

It means that I can basically use his 20k line library of code without having to change any of it!

I've thought of a class structure that will make it very easy to use too so all is good!

One question I've got though...

If I have a class that has a method in it called foo() and in that method it has a line run bar().

i.e. in TemplateClass
Code:
-(void) foo
{
    [self bar];
}

-(void)bar
{
    //nothing to see here.
    NSLog(@"In the super class");
}

and then I subclass the class and overwrite bar...
i.e. in ActualClass
Code:
-(void) bar
{
    //Doing something in the subclass
    NSLog(@"In the sub class");
}


If I then create an ActualClass object and run [myActualClass foo].

Which version of bar will it run. Which NSLog would I see?

Author:  finlay666 [ Wed Sep 21, 2011 8:45 am ]
Post subject:  Re: Woop! (Also a question about subclassing).

You would call yours as yours is the closest scope IIRC

If the obj-C is anything like C# you could also call base.methodname() to call the base method as well

Author:  Fogmeister [ Wed Sep 21, 2011 8:48 am ]
Post subject:  Re: Woop! (Also a question about subclassing).

finlay666 wrote:
You would call yours as yours is the closest scope IIRC

If the obj-C is anything like C# you could also call base.methodname() to call the base method as well

Cool, I thought that was the case but had a second of doubt so thought I'd ask.

I can check quite easily tonight but I'm at work atm.

Thanks

Author:  forquare1 [ Wed Sep 21, 2011 9:23 am ]
Post subject:  Re: Woop! (Also a question about subclassing).

Yes, It would act as Finley said. You could then call [super bar] to call the super classes bar method.

Author:  Fogmeister [ Wed Sep 28, 2011 8:41 am ]
Post subject:  Re: Woop! (Also a question about subclassing).

LOL!

Well it turned out that I didn't need to bother about subclassing or anythign. Did it a far simpler way.

I now have an object that is the middle-man for any communication with the C++ library and passes out proper Objective-C objects.

I also now have a properly working app! It still needs a hell of a lot of work but it's getting there! Woop!

Author:  forquare1 [ Wed Sep 28, 2011 4:56 pm ]
Post subject:  Re: Woop! (Also a question about subclassing).

Fogmeister wrote:
I now have an object that is the middle-man for any communication with the C++ library and passes out proper Objective-C objects.


I believe this is the Adaptor design pattern :ugeek:

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/