0

Are the objects/controls that you created using IB accessible from a class method?

@Nekto:

@interface CopyController : UIViewController
{
    UIActivityIndicatorView *myActivity;
}

@property (nonatomic, retain) IBOutlet UIActivityIndicatorView *myActivity;
+(void) activityIndicator:(BOOL)flag;

@end

This implementation in the .m will not be allowed, the error was "Instance variable'myActivety' accessed in class method".

+(void)activityIndicator:(BOOL)flag
{
    if (flag)
        [myActivity startAnimating];
    else
        [myActivity stopAnimating];
}
user523234
  • 14,323
  • 10
  • 62
  • 102
  • 1
    Please spend more time with the documentation provided by Apple before asking questions like this. This is the basics of working with IB, and if you are asking this, then you need to keep reading to really learn the tool before going further with your project. – Philip Regan Sep 07 '11 at 14:25
  • @Phil His question is regarding scope, not how to connect the outlet. – Beltalowda Sep 07 '11 at 15:56
  • @Thuggish Nuggets: Thanks. Phillip Regan: remove the down grade if you are satisfied!!!! – user523234 Sep 07 '11 at 16:07

2 Answers2

1

Yes, they are accessible.

You should add @property IBOutlet ib_object_class *ib_object_name;, open that object settings in IB and set reference outlet to File's Owner by selecting ib_object_name in drop down menu.

Full explanation can be found, for example, here : Creating and Connecting an Outlet

Nekto
  • 17,837
  • 1
  • 55
  • 65
  • I am aware of that process, my question was about the if it is accessible within the class method. That is where I encountered the problem. When I implement an instant method or private method, I can access those IB objects, but in the class method, it is not available. – user523234 Sep 07 '11 at 15:14
  • Then describe your problem correctly, post code, describe errors. I've answered your current question: yes, you can. – Nekto Sep 07 '11 at 15:23
  • 1
    Please see my edit to original question. I could not get the code pasted into this comment. – user523234 Sep 07 '11 at 15:50
0

You may be able to connect the outlet to the first responder instead of the file's owner to achieve this, but I don't think you can access it from within a class method since your IBOutlet property is going to be an instance-level variable.

Found something similar for linking actions to multiple first responders here.

Community
  • 1
  • 1
Beltalowda
  • 4,558
  • 2
  • 25
  • 33