+ Reply to Thread
Results 1 to 2 of 2

Thread: Newbie objectice-c class and property question

  1. #1
    Newbie ChrisMoses is an unknown quantity at this point
    Join Date
    Jun 2009
    Posts
    1

    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 01:13 PM. Reason: add code tags (the # button)

  2. #2
    Newbie CrazyJugglerDrummer is an unknown quantity at this point
    Join Date
    Jun 2009
    Posts
    2

    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

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. creating a Linked Queue class?
    By TshingY in forum C# Programming
    Replies: 3
    Last Post: 04-19-2009, 09:51 PM
  2. How to design a set of classes for a project.
    By WingedPanther in forum Tutorials
    Replies: 8
    Last Post: 12-11-2008, 05:19 PM
  3. PHP 5 and OOP
    By Jordan in forum PHP Tutorials
    Replies: 11
    Last Post: 09-22-2008, 01:58 AM
  4. Creating a Class in Visual Studios.Net (Visual Basic Section)
    By dream in forum Visual Basic Programming
    Replies: 11
    Last Post: 05-12-2008, 02:47 PM

Bookmarks

Bookmarks

     
        Algorithms and Data Structures

        Java tutorials

        Algorithms Forum

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts