November 2013
Beginner
325 pages
9h 47m
English
To see weak references in action, let’s add another array to the mix. What if you wanted an array of all assets – even ones that have not been assigned to a particular employee? You could add the assets to an array as they are created. Add a few lines of code to main.m:
#import <Foundation/Foundation.h> #import "BNREmployee.h" #import "BNRAsset.h" int main(int argc, const char * argv[]) { @autoreleasepool { // Create an array of Employee objects NSMutableArray *employees = [[NSMutableArray alloc] init]; for (int i = 0; i < 10; i++) { // Create an instance of BNREmployee BNREmployee *mikey = [[BNREmployee alloc] init]; // Give the instance variables interesting values [mikey setWeightInKilos:90 + i]; [mikey ...Read now
Unlock full access