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

  • Home
  • SEARCH
  • 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 6045081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:05:06+00:00 2026-05-23T07:05:06+00:00

Sorry for the noob question, but I’m starting to use structs in objective-c for

  • 0

Sorry for the noob question, but I’m starting to use structs in objective-c for the CG data types. If I create a new CGRect, and I set it to some view.frame, do they now point to the same thing in memory? Or are they two separate objects and if I change one, I will not change the other? Thx.

What is happening is I’m creating a CGRect and setting it to my view.frame. Then based on the data, I update the frame.size.height. However, in my else statement, I’d like to change it back to it’s original size, so if I then select a different object, it’s frame is large. It seems like once I set it the frame to a smaller size, it stays at that size.

CGRect frameToCenter = self.SView.frame;
CGFloat originalHeight = self.SView.frame.size.height;
//CGFloat originalHeight = 500.0; //if I hardcode it works.

if ([self.array count] == 1) {
    frameToCenter.size.height = totalRowHeight;
}
else {
    frameToCenter.size.height = originalHeight;
}
self.SView.frame = frameToCenter;

I don’t want to hard code anything, but I wanted to get the basic funcitonality working so I started with when I only have 1 in my array. And then for other numbers, the view would go back the original size. But once it hits that first if statement, it never gets its height changed. The only way I can make it change back is if I hardcode a CGFloat value before this block.

  • 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-23T07:05:07+00:00Added an answer on May 23, 2026 at 7:05 am

    First of all, CGRect is not an object at all. It sounds like you know that, but the question “are they two separate objects” hints at confusion on the point.

    Since you’re assigning the actual struct, and not a pointer to the struct, the assignment copies values from the origin to the receiver. After the assignment, changing one of them will have no effect on the other unless you do another assignment. So this code does not change the view’s frame:

    CGRect myRect = myView.frame;
    myRect.origin.x += 10.0;
    

    If I want to change the frame I need another line to assign the changed value back to the view’s frame:

    myView.frame = myRect;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In advance: sorry for the noob question but I'm learning Cocoa & Objective-C and
sorry for the noob question, but I'm new to C++. I need to read
I am new to drupal, so sorry for this noob question, but I was
sorry for the (probably) noob question, but I', new at this stuff. i have
Sorry for the noob question but I am pretty new to the Android SDK/Eclipse
Sorry this is a noob question but if I only need some initial data
Sorry for that noob question but is there any real needs to use one-to-one
I'm sorry for the very noob question, but I'm kind of new to bash
Sorry if this is kind of a noob question, but I'm just starting to
Sorry to ask such a noob question, but the NDK documentation is wrong (r7b):

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.