Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 831509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:12:57+00:00 2026-05-15T04:12:57+00:00

I know that I can’t use this: myView.frame.origin.x = 25.0; and that I have

  • 0

I know that I can’t use this:

myView.frame.origin.x = 25.0;

and that I have to use this instead:

CGRect myFrame = myView.frame;
myFrame.origin.x = 25.0;
myView.frame = myFrame;

And I’m doing it all the time, but I don’t know why I must do it that way. I would like to fill that gap in my understanding. Can someone explain ?

Nowadays Xcode gives you “Expression not assignable”. Some time ago you got a compile error “Lvalue required as left operand of assignment”.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T04:12:58+00:00Added an answer on May 15, 2026 at 4:12 am

    The reason this does not work is due to the mixing of two syntaxes.
    First you have “.” as a shortcut for calling the accessor functions (an Objective-C feature).
    So

    • a.b becomes [a getB];
    • a.b = 5 becomes [a setB:5];

    And then theres “.” as direct struct member access (pure C). So

    • a.b really is a.b;
    • a.b really is a.b = 5;

    Combining this in a set-value-case like this, doesn’t work.
    Because …
    If you could call

    myView.frame.origin.x = 25.0;
    
    • The “myView.frame” part equals [myView getFrame] and you get a copied CGRect frame (a C struct)

    • The “myView.frame.origin” gives you a CGPoint origin (also a struct) of the copied CGRect

    • The “myView.frame.origin.x = 25.0” gives you a CGFloat x of the origin and now you want to assign something to it and here comes the problem…

    You try to set a variable of a struct of a struct, which is ok, but there is no pointer from the UIView to the struct, so it is copied instead. So you copy and then you set and then you expect that the set action is somehow forwarded through the initial get to the UIView, well and this just doesn’t work.

    Of course you could wonder why Apple hasn’t just created a shortcut, so that in the end your copied frame is automatically reinjected into a auto appended setFrame call, I guess you just have to live with how it is.

    So remember, it would work if you’d get a pointer to the frame, but you don’t, you get a copied struct instead.
    So if you expect myView.frame.origin.x = 25.0 to work you indirectly expect your call to be automagically translated into some sort of
    [myView setFrame:[myView getFrame:frame].origin.x = 25.0].
    Well I guess you can admit that this looks wrong.

    Also imagine if you’d get a direct pointer to the CGRect frame and you’d change something through that pointer, how would the UIView know that it’s size has changed and that it has to update itself ? If on the other hand a [myView setFrame:newFrame] call is made, then UIView can do all the necessary readjusting itself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 2 questions: 1- We all know that can create an array list
I know that can't use left join in indexed view. but I don't understand
I just want to know that can i make an application which have some
I know that I can track when the mouse is moved like this: $(body).mousemove(
I know that I can copy the structure member by member, instead of that
We all know that you can simulate click or any other event on an
While we all know that x == y can be problematic, where x and
¿how can I know that things have happened rafters or on my server?, I've
We all know that the JRE will destroy any object that can no longer
I know that hundreds of variations of these considerations have been posted all over

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.