• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: CALayer properties
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CALayer properties


  • Subject: Re: CALayer properties
  • From: Charles Steinman <email@hidden>
  • Date: Tue, 28 Oct 2008 17:06:49 -0700 (PDT)

----- Original Message ----
> From: DKJ <email@hidden>
>
> When I did this:
>
>     myLayer.frame.size.width = rootLayer.frame.size.width;
>
> I got an "illegal lvalue" error. But when I do this:
>
>     CGRect r = help.frame;
>     r.size.width = rootLayer.frame.size.width;
>
> the compiler says nothing. Why can I use layer.frame.size on the right
> of =, but not the left?


You can't assign to the return value of a function or method. I think the dot syntax is confusing you because it looks the same between structs and object properties even though it does completely different things. The (myLayer.frame) part calls [myLayer frame], which returns an NSRect value. At that point, you have an NSRect value sitting outside of any variable, so you can't assign to it. What you're doing is similar to writing this:

[[NSObject alloc] init] = [NSString stringWithString:@"Hello world"];

Does that make more sense?

Cheers,
Chuck



_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

  • Prev by Date: Re: Getting localized NSPredicateEditor
  • Next by Date: Re: CALayer properties
  • Previous by thread: Re: CALayer properties
  • Next by thread: Re: CALayer properties
  • Index(es):
    • Date
    • Thread