开发者

Can't determine calling class's variable's value using XCode

开发者 https://www.devze.com 2023-02-17 18:08 出处:网络
Here\'s what I\'m looking to do.I have a UITableViewController that has a variable, bInternetOK, that I need to reference from a class that the UITableViewController instantiates.This way, the class c

Here's what I'm looking to do. I have a UITableViewController that has a variable, bInternetOK, that I need to reference from a class that the UITableViewController instantiates. This way, the class can make sure the internet is available before it tries to do some work. In the .h of the UITableViewController, I've defined the variable like this:

开发者_运维问答
Boolean bInternetOK;

And I've set a property like so:

@property (nonatomic) Boolean bInternetOK;

In the .m of the UITableViewController, I've synthesised the variable like this:

@synthesize bInternetOK;

I instantiate the class (TheNetworkClass) like this and then call the function to start the work:

TheNetworkClass *TheNetworks = [[TheNetworkClass alloc]init];
[TheNetworks StartUpTheWork];

Inside of the TheNetworkClass class, I'm trying to reference the variable bInternetOK that is in the UITableViewController class. How do I do this?

Thanks!


You could give the instance of your TheNetworkClass object a reference to your table view controller instance when you create it.

Or you could just give your TheNetworkClass object the boolean, if it only checks it on creation.

Or, if the table view can be accessed as a property on your application delegate, you can get the application delegate with [UIApplication sharedApplication].delegate and then access that property to get to the table view.

0

精彩评论

暂无评论...
验证码 换一张
取 消