New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

Trouble with Objective-c class


Post Reply New Thread Subscribe

 
Thread Tools
blevblev

 
Member Since: Mar 11, 2009
Posts: 2
blevblev is on a distinguished road

blevblev is offline
I'm an experienced programmer, but a newbie with Objective-C. I am using a sample I found on the internet as a model. All I tried to do, was add a new class to the project - that is, I'm not trying to use it yet, I'm just trying to get the program to compile. When I do, I get several error messages: in the .m file, after the initWithName I get "syntax error before NSString" and then after ever line except "name = nameValue" I get "type defaults to an int" and "addressValue undeclared here" and "data definition has no type or storage class." The strange thing is if I drop the last parameter (zip) it compiles ok. I've tried adding another parameter, but then it doesn't compile again. I also tried changing names around in case I was using reserved words or something (although the compiler should pick that up...)

Like I say, I'm just starting out. HELP! All I'm trying to do is make a class that uses "initialize with arguments" just to try it out.

By the way this editor insists on replacing a colon followed by a left parens with a smiley face. I can't figure out how to tell it not to.

Here's the code: here's Door.h

#import <Foundation/Foundation.h>

@interface Door : NSObject {
****NSString *name;
****NSString *dooraddress;
****NSString *city;
****NSString *state;
****NSString *zip;
}

@property (nonatomic, retain) NSString *name;
@property (nonatomic, retain) NSString *dooraddress;
@property (nonatomic, retain) NSString *city;
@property (nonatomic, retain) NSString *state;
@property (nonatomic, retain) NSString *zip;

-(id)initWithNameNSString *)nameValue
*******andAddressNSString *)addressValue
**********andCityNSString *)cityValue
******** andStateNSString *)stateValue
***********andZipNSString *)zipValue;

@end

and here's door.m

#import "Door.h"

@implementation Door
*
@synthesize name;
@synthesize dooraddress;
@synthesize city;
@synthesize state;
@synthesize zip;

-(id)initWithNameNSString *)nameValue
*******andAddressNSString *)addressValue
**********andCityNSString *)cityValue
******** andStateNSString *)stateValue
***********andZipNSSTring *)zipValue {
********
****name = nameValue;
****dooraddress = addressValue;
****city = cityValue;
****state = stateValue;
****zip = zipValue;

****return self;
****
}

@end
QUOTE Thanks
mystic_fm

 
Member Since: Mar 15, 2007
Posts: 161
mystic_fm will become famous soon enough
Mac Specs: 17" MacBook Pro, 2.33GHz C2D, 2GB RAM

mystic_fm is offline
For your zipValue parameter you have typed in NSSTring rather than NSString. That typo might be your problem.

As far as showing code in a forum post, look into surrounding your code blocks with the CODE tag (surrounded by square brackets, and also available via the '#' button in the advanced post editor's toolbar), which will give you results like this:

Code:
- (id) initWithName:(NSString *)nameValue
         andAddress:(NSString *)addressValue
            andCity:(NSString *)cityValue
           andState:(NSString *)stateValue
             andZip:(NSString *)zipValue;
QUOTE Thanks
blevblev

 
Member Since: Mar 11, 2009
Posts: 2
blevblev is on a distinguished road

blevblev is offline
That was it. I found out last night by re-typing part of the files, and the error went away. Thanks for the tip about posting code too....
QUOTE Thanks

Post Reply New Thread Subscribe


« using terminal to create a computer to computer network | Java - Ultimate Beginner help »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
help me convert something, please. krrose27 Switcher Hangout 4 05-25-2007 02:10 AM
Safari: CSS class not applied to form text boxes schoolyard Web Design and Hosting 1 04-05-2004 03:17 PM
Science class rman Schweb's Lounge 1 10-27-2003 05:34 PM

All times are GMT -4. The time now is 08:07 AM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?