|
|
#1 | |
|
error during variable setting
Hi @ all,
I have a problem in my class, In my class.m, I declared some NNString variable, all in same way. I "@"synthesized these, but someones thrown exceptions, others not. this is the myclass header code Code:
@interface Paziente : NSObject
{
NSString * name;
NSString * birth;
NSString * ID;
NSString * sex;
NSString * mTeGr;
NSString * vTeGr;
NSString * mCrGr;
NSString * vCrGr;
NSString * mCdGr;
NSString * vCdGr;
NSString * mTeM;
NSString * vTeM;
NSString * mCrM;
NSString * vCrM;
NSString * mCdM;
NSString * vCdM;
}
@property (nonatomic,retain)NSString * name;
@property (nonatomic,retain)NSString * birth;
@property (nonatomic,retain)NSString * ID;
@property (nonatomic,retain)NSString * sex;
@property (nonatomic,retain)NSString * mTeGr;
@property (nonatomic,retain)NSString * vTeGr;
@property (nonatomic,retain)NSString * mCrGr;
@property (nonatomic,retain)NSString * vCrGr;
@property (nonatomic,retain)NSString * mCdGr;
@property (nonatomic,retain)NSString * vCdGr;
@property (nonatomic,retain)NSString * mTeM;
@property (nonatomic,retain)NSString * vTeM;
@property (nonatomic,retain)NSString * mCrM;
@property (nonatomic,retain)NSString * vCrM;
@property (nonatomic,retain)NSString * mCdM;
@property (nonatomic,retain)NSString * vCdM;
@end
Code:
#import "Paziente.h" @implementation Paziente @synthesize mCdGr; @synthesize vCdGr; @synthesize mTeM; @synthesize vTeM; @synthesize mCrM; @synthesize vCrM; @synthesize mCdM; @synthesize vCdM; @synthesize name; @synthesize birth; @synthesize ID; @synthesize sex; @synthesize mTeGr; @synthesize vTeGr; @synthesize mCrGr; @synthesize vCrGr; @end Quote:
?
|
||
|
|
0
|
|
|
#2 |
|
From your error it looks like you were sending the message to the class, Paziente, and not the instance, p. I tested your code exactly and the . notation and setter for the member you were having problems with worked fine for me.
As an aside, post ALL the code. Post a small main.m that has the calls you make where you see a problem, so we can run it ourselves (or just see it). We'd probably be able to call out the problem immediately if you had done so. -Lee |
|
|
|
1
|
|
|
#3 |
|
Just some recommendations:
Don't write "NSString * variable". It looks like a multiplication. Use "NSString* variable" instead. Start all instance variables with an underscore. That way when you read the code you know exactly where instance variables are used, and where properties are used. |
|
|
|
1
|
|
|
#4 |
|
Very strange!
The debugger shows some variables of Paziente class. Like the instance of class is partially allocated. mmm |
|
|
|
0
|
|
|
#5 |
|
I created a new class,
I pasted the same code of the Paziente class. Now, it works fine. |
|
|
|
0
|
|
|
#6 |
|
There are class members. What you declared are instance members. You have to access them on an instance of the class instead of on the class itself. I'm guessing it worked the second time because you changed the code accessing it and used an object instead of the new class name. If you post all of your code before and after we can tell you for sure and you can learn by identifying the error. Copying to a new file and declaring success when the real change was tangential is the sort of superstition that's best to avoid.
-Lee |
|
|
|
1
|
![]() |
|
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
All times are GMT -5. The time now is 06:54 PM.




fView:untilMouseUp:] + 2295
?


Linear Mode
