To create a base class to manage our assets, we need to use the following steps:
Open the Xcode game template if it's not already open, right-click on the Classes folder, select New Group, and rename the group to Assets.
Right-click on the Assets group and select New File....
Select Objective-C class and click on Next.
Enter
AssetsDictionary
in the name field, select NSObject from the Subclass of entry, and click on Next.On the next dialog, click on Create.
Open the
AssetsDictionary.h
file.Add an instance variable called
_dict
, which is a pointer toNSMutableDictionary
, as shown in the following code:@interface AssetsDictionary : NSObject { NSMutableDictionary *_dict; }
Add a property called
verbose
, which is of typeBOOL
, as shown in the following code:@property BOOL verbose;
Add an instance method called
registerAsset
, as shown in the following code:-(id) registerAsset:(NSString *)name withContent:(id)content;
Add another instance method called
unregisterAsset...