Closed Thread
Results 1 to 2 of 2

Thread: Newbie objectice-c class and property question

  1. #1
    ChrisMoses is offline Newbie
    Join Date
    Jun 2009
    Posts
    1
    Rep Power
    0

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

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Jun 2009
    Posts
    2
    Rep Power
    0

    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

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. property from another class
    By jaiii in forum C and C++
    Replies: 6
    Last Post: 07-08-2010, 01:29 AM
  2. class/class pointer question
    By MerakSpielman in forum C and C++
    Replies: 2
    Last Post: 04-12-2009, 09:20 AM
  3. Newbie Question
    By SG123 in forum General Programming
    Replies: 4
    Last Post: 03-17-2009, 07:26 AM
  4. Newbie Question
    By british0zzy in forum C and C++
    Replies: 3
    Last Post: 07-18-2008, 07:57 PM
  5. Newbie question
    By cowdog88 in forum C# Programming
    Replies: 5
    Last Post: 02-11-2008, 03:55 PM

Tags for this Thread

Bookmarks

Posting Permissions

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