0

I am using a UIActivity Indicator View named as process.

I declare property in main.h class,and synthesize in main .m

i am using this to indicate user connecting web on a button click.

And [process startAnimating] that indicator in button click.

But I write code to connect web services in another class named webservices,now i need to stop animating that process in this web services.

For that i am writing code in webservices.m

main *obj = [[main alloc]init];
[obj.process stopAnimating];

But it not works.

can any one pls help me.

Thank u in advance.

Mahesh Babu
  • 3,395
  • 9
  • 48
  • 97

2 Answers2

0

The process property is declared in your first class (main?). You need to reference it from the same object as the first time: [mainObj.process stopAnimating]. You need to have a reference to the original instance of main.

You can make main a singleton or, much better, you can define a delegate protocol for webservices and main can tap as a delegate. This way webservices can notify main when it's done processing and main can stop the animation.

Ciprian L.
  • 587
  • 2
  • 7
0
main *obj = [[main alloc]init];
[obj.process stopAnimating];

you are creating another object of your main class here and stoping its process' activity indicator... rather than creating a new object you need to refer that process with which you have called [process startAnimating]

suppose i have one class

class ABC
{

//  Construction/Destruction
public:
                     ABC();
    virtual         ~ABC();
// member 
    int var1;

};

Now i am creating object of class ABC in file XYZ.cpp

ABC *abc_object1 = new ABC;
abc_object1->var1 = 5; 

Now i want to use this abc_object1's var1 in another class PQR.cpp

if i create another object as

ABC *abc_object2 = new ABC;
printf("value is %d",abc_object2->var1);

the value would be null or garbage and not 5 as we have set in XYZ.cpp because it is two different object/instance of the same class. you need to pass that abc_object1 from XYZ.cpp to PQR.cpp somehow... by function's argument most likely...

same applies to your code also... i hope this simple example clears your fundamentals of class

Mihir Mehta
  • 13,743
  • 3
  • 64
  • 88
  • i am using object-c language,any how what ever language i did n't get what u r saying simply you are saying "you need to pass that abc_object1 from XYZ.cpp to PQR.cpp" how can i pass it in my code – Mahesh Babu Jan 18 '11 at 08:59
  • like you pass normal variable in function... if you use [navController pushViewController:viewController1]; you need to take one uiactivityindicator variable in viewController1 and before pushing you need to assign the uiactivityindicator to your process from where you're pushing it... – Mihir Mehta Jan 18 '11 at 09:13