@eppinizer@eppinizer Objective-C has very stiff conventions that you don't break, for accessors, you ALWAYS use setIvar: and ivar. There are certain things that won't work either if you had getIvar as your getter. It's just the way it is and you may even learn to appreciate it.
@AppleProgramming Hmm interesting.... I googled the subject and got some more info pertaining to the subject.
Thank you very much for the tuts. I appreciate them a lot. I have a software idea and I am working on creating a cocoa/obj c prototype of it. I am going to continue to view your tutorials as well as follow along with Hillegass's "Cocoa programing for Mac OS X".
@Bob91355 it is very good software engineering practice to do because it means that only your class can access the variables directly and it is also good practice to use the getter/setter methods inside the actual class instead of accessing them directly.
@Bob91355 You'll see in the coming tutorials how this works. We don't we will always use "getter" and "setter" methods when accessing our instance variables from outside of the class. Apple leverages key technologies as well that rely on these accessor methods. I think you'll get it in the next few tutorials.
When you define your setHeight method (or any method), does it matter on which side of the equals sign the parameter sits? For example, is "height = newHeight" functionally identical to "newHeight = height" ? Thanks!
@ezimerman You need to be assigning your instance variable in your class. Since your Rectangle class has a width and height instance variable, these methods are used to assign each of those values. So yes, height = newHeight is what you need to do, because height is the only value that stays around. I'm not sure what exactly you are confused on, but if you don't know how to assign variables, make sure to check out the C tutorial I have on that.
Thank you for these tutorials, i find these very helpfull. i am 14 and have a great idea for an app so im getting together with some of my friends and learning this amazing computer language. Hopefully with enough practice i wil eventually see my app idea come to life
@stripabid I think pretty much everyone who has watched the C programming series knows how this works (function prototype and function definition). Basically, the @interface just sets up the method names, that's it. @implementation says how each method is going to function. In other words, what is each method going to do? If we didn't have @implementation, our methods don't know what their purpose is, they would just have their names. I'm deeply sorry that I didn't make this clear enough.
Why don't you call them getHeight/getWidth? That is what I'd probably use if I was writing in c++. Why is it different in ObjC?
eppinizer 3 weeks ago in playlist Objective-C Tutorials
@eppinizer @eppinizer Objective-C has very stiff conventions that you don't break, for accessors, you ALWAYS use setIvar: and ivar. There are certain things that won't work either if you had getIvar as your getter. It's just the way it is and you may even learn to appreciate it.
AppleProgramming 3 weeks ago
@AppleProgramming Hmm interesting.... I googled the subject and got some more info pertaining to the subject.
Thank you very much for the tuts. I appreciate them a lot. I have a software idea and I am working on creating a cocoa/obj c prototype of it. I am going to continue to view your tutorials as well as follow along with Hillegass's "Cocoa programing for Mac OS X".
Thanks for all of your hard work!
eppinizer 3 weeks ago
@Bob91355 it is very good software engineering practice to do because it means that only your class can access the variables directly and it is also good practice to use the getter/setter methods inside the actual class instead of accessing them directly.
Deeharok 7 months ago
What was the point of making a method to return your variables?
Thanks,
Your videos are great.
Bob91355 8 months ago
@Bob91355 You'll see in the coming tutorials how this works. We don't we will always use "getter" and "setter" methods when accessing our instance variables from outside of the class. Apple leverages key technologies as well that rely on these accessor methods. I think you'll get it in the next few tutorials.
AppleProgramming 8 months ago
@Bob91355 variables are private by default
dagr8master 5 months ago
When you define your setHeight method (or any method), does it matter on which side of the equals sign the parameter sits? For example, is "height = newHeight" functionally identical to "newHeight = height" ? Thanks!
ezimerman 9 months ago
@ezimerman You need to be assigning your instance variable in your class. Since your Rectangle class has a width and height instance variable, these methods are used to assign each of those values. So yes, height = newHeight is what you need to do, because height is the only value that stays around. I'm not sure what exactly you are confused on, but if you don't know how to assign variables, make sure to check out the C tutorial I have on that.
AppleProgramming 9 months ago
Thank you for these tutorials, i find these very helpfull. i am 14 and have a great idea for an app so im getting together with some of my friends and learning this amazing computer language. Hopefully with enough practice i wil eventually see my app idea come to life
lionbro05 1 year ago
@lionbro05 That's awesome, if you have any questions along the way, don't hesitate to ask.
AppleProgramming 1 year ago
@stripabid Thanks, I appreciate your honesty about the tutorial
AppleProgramming 1 year ago
@stripabid I think pretty much everyone who has watched the C programming series knows how this works (function prototype and function definition). Basically, the @interface just sets up the method names, that's it. @implementation says how each method is going to function. In other words, what is each method going to do? If we didn't have @implementation, our methods don't know what their purpose is, they would just have their names. I'm deeply sorry that I didn't make this clear enough.
AppleProgramming 1 year ago