views:

35

answers:

2

I've declared a property in a view (created by interface builder, if it matters) and am trying to set the value from the view's controller – like so:

self.view.url = someURL;

That gives this error:

Request for Member 'url' in something not a structure or union

I have included the header for the view in the controller's .m file, but I'm probably just doing something wrong, but I don't know what – any ideas?

The view code:

@interface PDFView : UIView {
    NSURL *url;
}

@property (nonatomic, retain) NSURL *url;

@end

@implementation PDFView

@synthesize url;
+2  A: 

I suspect the problem is that "self.view" is of type UIView (since it's inherited from UIViewController), not PDFView, so the compiler doesn't recognize that there's a "url" property on it.

What happens if you do?

  PDFView *aView = self.view;
  aView.url = someURL;
David Gelhar
Yeah, silly mistake on my part – I did some setup in IB and some procedurally, but didn't do either completely.
Mark McDonald
+1  A: 

Inside your subclass of UIViewController, the self.view refers to the ViewController's big view which is a UIView. Your PDFView should be a subview in self.view if you added it in IB.

You need to add PDFView to your view controller's .h file with an IBOutlet, connect it in IB and then refer to it thru the outlet that you declared in your view controller.

progrmr