Skip navigation.
 
mlRe: Using dot syntax for non-@property properties?
FROM : listposter
DATE : Wed Nov 07 03:14:06 2007

On $BJ?@.(B 19/11/07, at 10:30, Joshua Emmons wrote:

> One of the dot syntax "Usage Summaries" from "The Objective-C 2.0 
> Programming Language" is:
>
> xOrigin = aView.bounds.origin.x;
>
> This leads me to believe that I can replace the following code:
>
> -(void)viewClicked:(id)sender{
>  NSSize size = [sender bounds].size;
>  size.height *= 2;
>  [[sender animator] setBoundsSize:size];
> }
>
> with something like:
>
> -(void)viewClicked:(id)sender{
>  NSSize size = sender.bounds.size;
>  size.height *= 2;
>  sender.animator.boundsSize = size;
> }
>
> However, when I do so, I get errors like "request for member 
> 'bounds' in something not a structure or a union". It sounds to me 
> like the compiler has no idea what's going on with the dot there. 
> Or, at least, it's definitely not [sender bounds], which is what I 
> would have expected. What am I overlooking here?

You can declare a property in a category, like so:

@interface NSView (Properties)
@property (assign) NSRect bounds;
@end


@interface NSView (Properties)
@dynamic bounds;
@end


As long as there is a <key> and set<key> method pair, you can "tack" 
on a property.
I've done it for some pre-leopard objects such as a subviews property 
etc on NSView...

Andre

>
> Many thanks,
> -Joshua Emmons
>
> _______________________________________________
>
> Cocoa-dev mailing list (<email_removed>)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>
> This email sent to <email_removed>

Related mailsAuthorDate
mlUsing dot syntax for non-@property properties? Joshua Emmons Nov 7, 02:30
mlRe: Using dot syntax for non-@property properties? mmalc crawford Nov 7, 02:40
mlRe: Using dot syntax for non-@property properties? listposter Nov 7, 03:14
mlRe: Using dot syntax for non-@property properties? Ali Ozer Nov 7, 03:32
mlRe: Using dot syntax for non-@property properties? Andre Nov 7, 06:32