error: property 'frame' not found on object of type 'UIView *'

23,225

Solution 1

If you hate typecasting every time, you can try this:

(lldb) expr @import UIKit
(lldb) po self.view.bounds

Since Xcode 7.2 is now available, I think we should update the answer.
I find the answer here, Why can't LLDB print view.bounds?

Solution 2

Try this

p (CGRect)[view frame]

Alternative to get the frame of the view:

po view

Solution 3

Try this,

po view.layer.frame.size.height

Solution 4

it should have outer bracket in the first answer,like this:

p ((CGRect)[cell frame])

output:

(CGRect) $5 = origin=(x=0, y=0) size=(width=320, height=44)

Solution 5

Add a pch file , add these lines of code to the file:

#ifndef PrefixHeader_pch
#define PrefixHeader_pch

#ifdef __OBJC__
#import <UIKit/UIKit.h>
#endif  

#endif /* PrefixHeader_pch */    

Next, link the pch file to your project:

enter image description here

Run the app again, then you should be able to use the dot notation in lldb console:

(lldb) po self.view.bounds    

For how to add a pch file , see the answer here PCH File in Xcode 6

Share:
23,225
HelenaM
Author by

HelenaM

Updated on July 18, 2022

Comments

  • HelenaM
    HelenaM almost 2 years

    I'm debugging my code and trying to figure out the size of the view using this:

    p view.frame.size.height
    

    but I'm getting this error:

    error: property 'frame' not found on object of type 'UIView *' error: 1 errors parsing expression

    any of you knows why or how can I debug the size of my view?

  • HelenaM
    HelenaM about 11 years
    I get this error: error: Execution was interrupted, reason: EXC_BAD_ACCESS (code=2, address=0x65). The process has been returned to the state before execution.
  • Avner
    Avner over 7 years
    I got the EXC_BAD_ACCESS because I was calling frame on the wrong object. Instead of: p (CGRect)[myviewcontroller frame] should be p (CGRect)[[myviewcontroller view] frame]
  • Trev14
    Trev14 over 5 years
    This worked for me, thank you. Makes me think that view.frame is simply be a shortcut for view.layer.frame that LLDB doesn't have access to...
  • iOS4Life
    iOS4Life over 3 years
    this worked in my case, trying to get [self traitCollection]; Dot notation failed with error, "property 'traitCollection' not found on object of type 'UIView *'", but using [self traitCollection] worked!