I've looked around and couldn't find a distinct answer to this question. So I'm asking here. I have two classes. ClassA and ClassB. I have a bool value in ClassB. I have a method in ClassA where it is looking for that value in ClassB to be True in order for the method to fire off. I'm not really sure how to get ClassA to see that value. Any help would be great. Thanks in advance!
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
be careful with the "global definition". if your class must save the user settings, you can use: for save:
NSUserDefaults *pref = [NSUserDefaults standardUserDefaults];
[pref setBool:YES forKey:@"AudioIsON"];
[pref synchronize];
for reading:
BOOL myBooleanSetting = [[NSUserDefaults standardUserDefaults] boolForKey:@"AudioIsON"];
instead of, is better to learn the delegate and the property.
hope this help you.