I’m learning objective c with some online tutorials and i have a question. On this video: http://www.youtube.com/watch?v=Nb9-1rRjO_8&feature=player_detailpage#t=367s you can see the code i wrote here:
@synthesize width, height; //setters and getters
-(void) setWH:(int) w:(int) h{
width = w;
height = h
}
I don’t understand why he wrote a setHW method if he already got setters and getters for width and height with @synthesize. What am i missing?
Thanks
He is synthesising width and height, but the method you are asking about
setWHlooks lie a badly named convenience method to set the width and height in one place.Actually, it looks quite bad, apart from not using
self.widthandself.heightas he should do, having asetfor something that isn’t a property looks odd.Where’s the
init?Find a better teacher.
If you like watching videos – fire up iTunes, go to iTunesU look up C193P, which is a video set of Stanford’s iPhone programming course. You’ll learn a lot more correctly there.
Edited to add
The link to this course on iTunes is https://itunes.apple.com/gb/itunes-u/ipad-iphone-application-development/id473757255