fuzzygoat
fuzzygoat

Reputation: 26223

With and Without Dot Notation?

I am trying to write the following without using dot notation ...

[scrollView setMinimumZoomScale: scrollView.bounds.size.width / image.size.width];

Is this right?

[scrollView setMinimumZoomScale: [scrollView bounds].size.width / [image size].width];

cheers Gary.

Upvotes: 0

Views: 230

Answers (1)

Matt Long
Matt Long

Reputation: 24476

There actually is something wrong with dot notation. It can get really ugly and hard to read in objective-c. While you'll get differing opinions and flame wars (which I probably just started), I'll be glad to share with you my rule of thumb. Use dot notation for structs. Use brackets for everything else. Read Joe Conway's (of Big Nerd Ranch) blog post on the subject.

Money quote from Joe:

It is my belief, after teaching roughly 300 students Objective-C, that dot-notation is confusing. It hinders the main goal of software development: writing maintainable, effective, efficient, easy to read and bug-free code.

In answer to your question, YES! Looks perfect. You're accessing a struct with your dots.

Stick to your guns on the dot notation. Don't let anyone bully you into using them. ;-)

-Matt

Upvotes: 5

Related Questions