objective c - Objects and Classes -


I came from a Java background, I know how to call methods with objects, but the following would be impossible?

  Main () {int v1 = 2; Int v2 = 3: int sum; Sum = [add: v1, (v2)]; } Add ((int) v1, (int) v2)) {return v1 + v2; }  

And my second question, how would I define a variable that is stable in all instances of an object? For example, if I want variable tax_rate to be .07 in every instance of an object, then

Methods have been written and written in a different way in Objective-C. A method definition may look like this:

  - (int) addThis: (int) v1 and that is: ( Int) v2 {return v1 + v2; }  

and you will apply it like this:

  int v1 = 2; Int v2 = 3; Int sum = [self addThis: v1 and that: v2];  

Syntax object (or classes) with parentheses is for methods if you are calling a plain old function, syntax C. Is similar to


Comments