0

In my code, i have a class , mainClass , which has an instance method -(void)record . In the interface of mainClass , i have instance variable,which used by this method.

Now, i know that every time i am creating a new instance of the class with :

mainClass *instance=[mainClass alloc];

its creating a new place in memory to all this class variables , and now if i do

[instance record];

it will create all the variables that are in record but they will be new once.

Now lets say i want to call from an outside class to record , and change/use its variables not create new once, but use the once already created in the mainClass.

whats the best way of doing this, and what it has to do with a class method ? Should this method be a class method? if yes , why ?

user1280535
  • 347
  • 3
  • 13

1 Answers1

1

If you want it accessible, instance and permanent changed you have to make it static, will answer your next question

Objective C Static Class Level variables

Community
  • 1
  • 1