Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

arfius

macrumors newbie
Original poster
Oct 31, 2012
3
0
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

whereas the .m code is
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

for example, if I set the variable "birth" p.birth=@"", it works; otherwise if I set the variable p.mTeM it doesn't work, I tried to use the method [p setMTeM:mad:""], but it is the same. This is the generated error.
-[Paziente setMTeM:]: unrecognized selector sent to instance 0x2e4bff0
2012-10-31 15:48:24.089 OsiriX[9976:1903] -[Paziente setMTeM:]: unrecognized selector sent to instance 0x2e4bff0
2012-10-31 15:48:24.091 OsiriX[9976:1903] (
0 CoreFoundation 0x90f14a67 __raiseError + 231
1 libobjc.A.dylib 0x9240c149 objc_exception_throw + 155
2 CoreFoundation 0x90f18070 -[NSObject doesNotRecognizeSelector:] + 256
3 CoreFoundation 0x90e66cd9 ___forwarding___ + 457
4 CoreFoundation 0x90e66aa2 _CF_forwarding_prep_0 + 50
5 Piomot_Plugin-pancreas 0x0c8053ad -[pancreas_PluginFilter rmt2x:] + 5645
6 CoreFoundation 0x90e69d11 -[NSObject performSelector:withObject:] + 65
7 AppKit 0x918ee663 -[NSApplication sendAction:to:from:] + 232
8 AppKit 0x918ee540 -[NSControl sendAction:to:] + 102
9 AppKit 0x918ee443 -[NSCell _sendActionFrom:] + 160
10 AppKit 0x918ed800 -[NSCell trackMouse:inRect:eek:fView:untilMouseUp:] + 2295
11 AppKit 0x91970a95 -[NSButtonCell trackMouse:inRect:eek:fView:untilMouseUp:] + 501
12 AppKit 0x918ec243 -[NSControl mouseDown:] + 943
13 AppKit 0x918b5dcd -[NSWindow sendEvent:] + 7533
14 AppKit 0x9184ef77 -[NSApplication sendEvent:] + 4788
15 AppKit 0x917e0b21 -[NSApplication run] + 1007
16 AppKit 0x91a71ac5 NSApplicationMain + 1054
)

can someone can help me :) ?
 
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
 
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.
 
Very strange!
The debugger shows some variables of Paziente class.
Like the instance of class is partially allocated.
mmm
 
I created a new class,
I pasted the same code of the Paziente class.
Now, it works fine.
 
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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.