Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Oct 31, 2012, 09:53 AM   #1
arfius
macrumors newbie
 
Join Date: Oct 2012
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
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:@""], but it is the same. This is the generated error.
Quote:
-[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:inRectfView:untilMouseUp:] + 2295
11 AppKit 0x91970a95 -[NSButtonCell trackMouse:inRectfView: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 ?
arfius is offline   0 Reply With Quote
Old Oct 31, 2012, 10:59 AM   #2
lee1210
macrumors 68040
 
lee1210's Avatar
 
Join Date: Jan 2005
Location: Dallas, TX
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
lee1210 is online now   1 Reply With Quote
Old Oct 31, 2012, 04:56 PM   #3
gnasher729
macrumors G5
 
gnasher729's Avatar
 
Join Date: Nov 2005
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.
gnasher729 is offline   1 Reply With Quote
Old Nov 5, 2012, 03:40 AM   #4
arfius
Thread Starter
macrumors newbie
 
Join Date: Oct 2012
Very strange!
The debugger shows some variables of Paziente class.
Like the instance of class is partially allocated.
mmm
arfius is offline   0 Reply With Quote
Old Nov 5, 2012, 07:53 AM   #5
arfius
Thread Starter
macrumors newbie
 
Join Date: Oct 2012
I created a new class,
I pasted the same code of the Paziente class.
Now, it works fine.
arfius is offline   0 Reply With Quote
Old Nov 5, 2012, 09:59 AM   #6
lee1210
macrumors 68040
 
lee1210's Avatar
 
Join Date: Jan 2005
Location: Dallas, TX
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
lee1210 is online now   1 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Environment variable not setting correct path to libcache.dylib rchaud10 iPhone/iPad Programming 3 Jun 12, 2013 04:47 PM
Setting wallpaper error RylanH16 iOS 6 1 Feb 10, 2013 07:07 PM
How i can fix "Wiki setting error" and "Running time error" ? Amethyst Mac OS X Server, Xserve, and Networking 0 Sep 2, 2012 01:34 PM
Variable is not a CFString at this time - Error Young Developer iPhone/iPad Programming 7 Aug 27, 2012 04:35 PM
Setting up OSX 10.8 server and get an error - invalid DNS name, help? hankkosovo Mac OS X Server, Xserve, and Networking 2 Aug 10, 2012 05:32 PM

Forum Jump

All times are GMT -5. The time now is 09:14 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC