I am just learning Objective C and was wondering what the correct way to create and use a class is.
In C# I can do something like:
Void MyMethod()
{
MyClass clsOBJ1 = new MyClass();
clsOBJ1.Name = “Fred”;
}
Or even
MyClass clsOBJ2;
Void MyMethod()
{
clsOBJ2 = new MyClass();
}
Void MyMethod2()
{
clsOBJ2.Name = “Bob”;
}
How would you achieve something similar in OBJ C?
I have tried this in OBJ C:
MyClass clsOBJ3 = [[[MyClass alloc]init]autorelease];
But I get the error message ‘MyClass Not Declared’
Thanks 🙂
I need to see more of your code to be sure but my guess would be that you havent imported the header for
MyClassAt the top of your file look for:
Or something similar