2

I have an a property declared in .h as

@property (nonatomic, assign) int timeSig_Numerator;

and an instance variable declared in the .h as

int mTimeSig_Numerator;

in the .m I synthesize with

@synthesize timeSig_Numerator = mTimeSig_Numerator;

I have a C function declared before the synthesize and need to use mTimeSig_Numerator. what is the best way to make the instance variable visible to my C function without passing it in as a function argument?

1 Answer 1

4

Since mTimeSig_Numerator is an instance variable, each instance of your class has its own mTimeSig_Numerator. As a C function is decoupled from any given class/class instance, how would it know from which instance it should obtain mTimeSig_Numerator?

Your C function needs either an argument containing the value of mTimeSig_Numerator in a specific instance, or an argument pointing to the instance itself, or some other mechanism that tells the function which specific instance/instance variable it should use.

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

1 Comment

I see, I hadn't thought about the C function not being 'part' of the class. Thank you.

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.