0

So, this might be a really simple question and if it's obvious, I'd like to apologise now but I couldn't find answers to it anywhere. So, here it is. Supposing I have a class:

@interface MyClass : NSObject

@property int Radius;
@property int Iterations;
@property UInt32 * Data;

@end

and in my implementation file I have:

@interface MyClass()

void Foo(int * newData);

@end

@implementation MyClass

// Synthesize block
// Getter-Setter block

void Foo(int *newData) {
    // Do some stuff
    _Iterations++;                   // Use of undeclared identifier _Iterations
    Iterations++;                    // Use of undeclared identifier Iterations
    self.Iterations++;               // Use of undeclared identifier self
}

@end

Could someone explain why I'm having this error and how I should go about fixing it?

Thanks,

9
  • I assume your "Foo" is a method. If it is, then this is how you create a method in Obj-C: - (void) Foo:(int)newData { _Iterations++; } Commented Aug 17, 2015 at 7:51
  • @PepengHapon No, Foo is a C-style function Commented Aug 17, 2015 at 7:58
  • @Woody1193: That is the problem. You have defined it as a (global) C function, which is unrelated to the class, and therefore has no access to any instance variables. Commented Aug 17, 2015 at 8:01
  • I messed up my own answer (too quick to type) and so I'll leave the door open for @MartinR or someone else to answer this one. Commented Aug 17, 2015 at 8:03
  • 2
    @Woody1193 - "C is not an object-oriented programming language. Since there's no such thing as an object in C, there's also no such thing as an instance variable in C..." From this ref, i think you can read about : stackoverflow.com/questions/5268579/… Commented Aug 17, 2015 at 8:04

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.