|
||||||
| C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
Newbie objectice-c class and property question
Hi everyone,
I'm not 100% certain that this fourm deals with Objective-C, but it is the closest I could find. If it does not, please excuse me (and can you recommend a forum for OC). I'm an experienced programmer but am brand new to Objective C. My learning was going well until I hit the following problem - I just want to create a class, instantiate it, and set/get the value for a property (of type NSInteger). Unfortunately, it doesn't work. I get a compiler warning saying: "warning 'SimpleClass' may not respond to '-simpleValue' " It isn't just a compiler warning complaining about the order of things in the file. It doesn't work at all. When it his the [myClass simpleValue:10]; it steps ito the assembly code and then exits the function. The console shows: *** -[SimpleClass simpleValue:]: unrecognized selector sent to instance 0x11a300 I've tried a couple of ways of casting the value, 10, to an NSInteger, but either I'm not doing it correctly, or it is not the problem. Any help would be greatly appreciated. Thanks in advance, Chris Code:
#import <Cocoa/Cocoa.h>
@interface SimpleClass : NSObject {
NSInteger simpleValue;
}
@property (assign) NSInteger simpleValue;
@end
#import "SimpleClass.h"
@implementation SimpleClass
@synthesize simpleValue;
@end
***** THE PROPERTY IS USED IN THIS METHOD ***********
@implementation CustomTypeProperty
- (IBAction)click_CustomPropertyType:(id)sender {
SimpleClass *myClass=[[SimpleClass alloc] init];
[myClass simpleValue:10]; //**** WARNING MESSAGE ON THIS LINE ****
NSLog(@"DONE"); // *** NEVER HIT ***
}
@end
Last edited by WingedPanther; 06-19-2009 at 02:13 PM.. Reason: add code tags (the # button) |
|
|||
|
Re: Newbie objectice-c class and property question
the syntax is just a bit off. The getter and setters than are syntesized start with set/get then the name of the property in camel case. try
[myClass setSimpleValue:10]; I'm not sure if you can use dot syntax for properties, but try it for objective c questions I reccomend a mac forum or stackoverflow.com |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| creating a Linked Queue class? | TshingY | C# Programming | 3 | 04-19-2009 10:51 PM |
| How to design a set of classes for a project. | WingedPanther | Tutorials | 8 | 12-11-2008 06:19 PM |
| PHP 5 and OOP | Jordan | PHP Tutorials | 11 | 09-22-2008 02:58 AM |
| Creating a Class in Visual Studios.Net (Visual Basic Section) | dream | Visual Basic Programming | 11 | 05-12-2008 03:47 PM |
All times are GMT -5. The time now is 10:59 AM.
Amrosama.cc
Arekbulski.cc
Debtboy.cc
Guest.cc
Jaan.cc
James.cc
Mathx.cc
Tsz.cc
Vswe.cc