I have a few variables in a .h called PListData.h
Code:
BOOL musicOn, soundOn;
@interface PListData : NSObject
{
}
//methods for saving to / getting from plist
Now you'll notice they are above the @interface, aka, can be accessed from any file. I have it set up so I can just call them directly knowing they have the same value. These variables get set and checked in various files throughout my project (when it saves the new value for whether sound/music is on, or when it checks the value before playing a sound file).
HOWEVER, when I decided we needed box2D in our project, I changed one of my implementation files from ' .m ' to ' .mm ' (enables Objective-C and C++ in the same file, or so they say). When I tried running to my device to make sure this change went smoothly, I received a linker error:
Code:
ld: duplicate symbol _musicOn in /Users/KeitZer/Library/Developer/Xcode/DerivedData/iGolfMini-afhuszztmyjgvxcjskpqmdgcquou/Build/Intermediates/iGolfMini.build/Debug-iphoneos/iGolfMini.build/Objects-normal/armv6/HoleDisplayLayer.o and /Users/KeitZer/Library/Developer/Xcode/DerivedData/iGolfMini-afhuszztmyjgvxcjskpqmdgcquou/Build/Intermediates/iGolfMini.build/Debug-iphoneos/iGolfMini.build/Objects-normal/armv6/AppDelegate.o for architecture armv6
collect2: ld returned 1 exit status
Command /old Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-g++-4.2 failed with exit code 1
I am aware this means it's being seen in both HoleDisplayLayer.mm and AppDelegate.mm but doesn't this mean that musicOn is being declared twice? I only set musicOn in the PListData.m when I get the information from th plist, and get musicOn in files that have music playing.
Anyways, the question I had was regarding how to fix it. Maybe I did it wrong, but when I tried using them as instance variables with getters and setters, it wouldn't retain the value (isn't there retain with @property?, but that's Objects-only, right?) through multiple classes. Like, let say I call the set method in the Menu class, but when I call the get in the Display, it returns a different value. Now, I was using [[PListData alloc] setMusic] format, which iirc doesn't save since isn't that a new instance of PListData?
How can I go about using variables through multiple classes?
Any questions left unaswered, feel free to ask and I'll do my best to answer.
Thanks,
KeitZer