Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > Mac OS X Development Forums > Objective-C, Python, Ruby Development

Reply
 
LinkBack Thread Tools Display Modes
Old 11-13-2009, 12:05 PM   #1 (permalink)
Registered Member
 
Join Date: Oct 2009
Posts: 39
Arcadiu is on a distinguished road
Default Inheritence!

Sorry, I have had a break from Objective C so I am going through this book making practice code because the book fails to put in exercises.

I have become frustrated as I am not able to get the class Second to inherit from the class first!

I also get a warning on [second print] saying second may not respont to -print and another warning on Second *second = [[Second alloc] init];
saying Second may not respond to +alloc

Finally, my actual error says it cannot find interface decleration for 'First', superclass of 'Second'.

This is my code and I would be really grateful if someone could point out the error.

Code:
#import <Foundation/Foundation.h>

@interface Second : First
{
}
@end

@implementation Second
@end




////////////////////////////////////////////////////////////////////////////////////
@interface First : NSObject
{
	
}
-(void) print;

@end

@implementation First

-(void) print 
{
	NSLog(@"Test");
}

@end

////////////////////////////////////////////////////////////////////////////////////

int main (){
	
	First *first = [[First alloc] init];
	Second *second = [[Second alloc] init];
	[second print];
	[first print];
	return 0;
}
__________________
Ultimate Pointer Website For Beginners (It Even Helped Me Understand)

http://www.cs.ucr.edu/~pdiloren/C++_Pointers/
Arcadiu is offline   Reply With Quote
Old 11-13-2009, 12:49 PM   #2 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 35
Nanyko is on a distinguished road
Default

Files are parsed top to bottom. At the point where you declared the interface of the 'Second' class, the compiler doesn't yet know a 'First' class exists because you declared it further down. Try declaring the 'First' class first, and then the 'Second' one.
__________________
Nanyko is offline   Reply With Quote
Old 11-13-2009, 01:18 PM   #3 (permalink)
Registered Member
 
Join Date: Oct 2009
Posts: 39
Arcadiu is on a distinguished road
Default

wow! never knew that! thankyou very much!
__________________
Ultimate Pointer Website For Beginners (It Even Helped Me Understand)

http://www.cs.ucr.edu/~pdiloren/C++_Pointers/
Arcadiu is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 459
11 members and 448 guests
Domele, Duncan C, Feldspar, MacBook MH, Objective Zero, peterwilli, pipposanta, Punkjumper, SLIC, taylor202, Today's Posts
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,694
Threads: 94,137
Posts: 402,950
Top Poster: BrianSlick (7,990)
Welcome to our newest member, peterwilli
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:05 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0