0

Hi my code generates the following exception :

[Dot position]: unrecognized selector sent to class 0x58a8.

What I do is I add instance of class Dot, to an NSArray (which is a property called dots) and then I try to get it back with;

Dot *last = [self.dots lastObject];

and print values inside C struct called position of type "CGPoint", last.position.x and last.position.y.

@property (nonatomic, readwrite) CGPoint position; 

is witten inside Dot class .h file, which I also import to where I make a call to CGPoint getter.

Casting value returned from the array with (Dot*) does not help as well. Explicit addition of -(CGPoint) position to Dot .h file has no effect either.

Line generating the exception is:

NSLog(@"Dot added at: X : %f Y: %f", last.position.x, last.position.y);
4
  • 4
    Have you @synthesize'd the property? Commented Dec 23, 2011 at 16:17
  • 2
    Did you synthesize the properties? Commented Dec 23, 2011 at 16:18
  • I synthesize in my Dot.m file, do I have to do that in other files If I mention getters/setters for properties of Dot? @synthesize position = _position; Commented Dec 23, 2011 at 18:35
  • Also I noticed +[Dot position]:unrecognized selector sent to class 0x58a8. Seems like it tries to message the class itself not an instance of it? Commented Dec 23, 2011 at 18:43

1 Answer 1

1

Error found, I had a Class method where I was returning, what I was thinking instance of Dot, I was doing it using [Dot alloc] init] where this returns Class object, I should have used [self alloc] init], to return instance of a Dot instead.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.