Reputation: 11476
Objective-C - image.size.width works but [[image size] width] doesn't. Message notation for struct CGSize?
I'm a big fan of classic message notation in Objective-C, don't know why but it just clicks.
image.size.width works and returns and int, however [[image size] width] doesn't
I understand why it doesn't, [image size] returns a CGSize struct which is C, and message notation doesn't work there. However using image.size.width just masks everything and it seems everything is like C, which it isn't.
How would message notation combine with this to keep both Objective and C expressiveness?
Upvotes: 0
Views: 52
Reputation: 4585
[image size]
return CGSize
. CGSize
is C's struct.
You can use []
only for objective-c.
.width
isn't message in that case, it's direct access to member of struct.
So you can write only: [image size].width
if you opponent of convenient dot-notation.
Upvotes: 2
Reputation: 101
I recommend to you the use of NSStringFromCGSize
NSLog(NSStringFromCGSize(image.size));
Upvotes: -1