Reply to topic  [ 6 posts ] 
Woop! (Also a question about subclassing). 
Author Message
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
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?

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Wed Sep 21, 2011 8:32 am
Profile WWW
Spends far too much time on here
User avatar

Joined: Thu Apr 23, 2009 9:40 pm
Posts: 4876
Location: Newcastle
Reply with quote
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

_________________
Twitter
Charlie Brooker:
Macs are glorified Fisher-Price activity centres for adults; computers for scaredy cats too nervous to learn how proper computers work; computers for people who earnestly believe in feng shui.


Wed Sep 21, 2011 8:45 am
Profile
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
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

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Wed Sep 21, 2011 8:48 am
Profile WWW
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 6:36 pm
Posts: 5150
Location: /dev/tty0
Reply with quote
Yes, It would act as Finley said. You could then call [super bar] to call the super classes bar method.


Wed Sep 21, 2011 9:23 am
Profile WWW
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
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!

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Wed Sep 28, 2011 8:41 am
Profile WWW
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 6:36 pm
Posts: 5150
Location: /dev/tty0
Reply with quote
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:


Wed Sep 28, 2011 4:56 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 6 posts ] 

Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.