When I call my urlconnection method from my (IBAction)buttonpressed method like this:
[self connectWeb];
I get error “request for member connectWeb in something not a structure or union”
but when I call the same method from my – (void)viewDidLoad method it works!?
Where is the
connectWebmethod in your implementation file?I would guess that it is before
viewDidLoadbut afterbuttonPressed.The reason for this is that the
connectWebmethod has been declared beforeviewDidLoad, soviewDidLoadis aware of it, whereas it’s after thebuttonPressedmethod, so thebuttonPressedmethod isn’t aware of it.You have a couple of options.
- (void)connectWeb;Then you can implement it anywhere within the implementation.
connectWebto before bothviewDidLoadandbuttonPressed– both the methods will then be aware ofconnectWeb.