i am getting the web services from the .net web server.
while in the process (getting data) i am displaying a subview with activity indicator.
After completing getting data i need to close that view.
i have two classes one is myclassviewcontroller,webservices
Basically i am writing code to get web services webservices.
In webservices class at
-(void)connectionDidFinishLoading:(NSURLConnection *)connection i call myclass like this.
myclassviewcontroller *obj = [[myclassviewcontroller alloc]init];
[obj mymethod];
At myclassviewcontroller i write this code for my method.
-
(void)mymethod {
[loadview removeFromSuperview];
}
the method is executed but view is not removed.
I already declared it in myclassviewcontroller.h class also.
i am checking this by keeping some text in NSlog
But if i calling this mymethod in myclassviewcontroller.m using timer then it removes view.
what the wrong.
can any one please help me.
I think it may be understand what is my problem.Let me place comment if not.
Thank u in advance.
I believe the problem with your code is how you access the
myclassviewcontroller. It must have already been on the screen while the data was loading, so creating a new instance of that class and calling a method against one of it’s uninitialized members (loadview) does nothing.If obj was a reference to the actual viewcontroller that is on screen, you could easily call:
or
So, the real problem is that you accessing a different instance of
myclassviewcontrollerthan the one which is actually on screen. You need a variable holding some reference to the correct instance ofmyclassviewcontrollerto access theloadviewivar.In
webservices.h:and
webservices.mwould need to@synchronize viewController.Then in
connectionDidFinishLoading:you can just call[viewController.loadview removeFromSuperview];