Hey guys, I have been doing a tutorial and this is what my code looks like:
One thing I have been having trouble with is my retainCount keeps saying I have a retainCount of 1, even though the myCar object has been released, followed by a pool drain.
I even tried putting my NSLog for the Retain Count at the very bottom, right above the return 0; }
Shouldn’t it be a retainCount of 0?
write [pool drain]; again just creates a memory leak.
'preciate any and all help
Code:
#import <Foundation/Foundation.h>
#import "SimpleCar.h"
int main (int argc, const char* argv[]) {
NSAutoreleasePool* pool = [NSAutoreleasePool alloc] init];
SimpleCar* myCar = [[SimpleCar alloc] init];
NSNumber* newVin = [NSNumber numberWithInt:123];
NSNumber* newEnginesz = [NSNumber numberWithFloat: 2.1];
[myCar setVin:newVin];
[myCar setEnginesz:newEnginesz];
[myCar setMake:@"Honda" andModel:@"Civic"];
NSLog(@"The car is %@ %@", [myCar make], [myCar model]);
NSLog(@"The vin is: %@", [myCar vin]);
NSLog(@"Engine size: %@". [myCar enginesz]);
[myCar release];
[pool drain];
NSLog(@"retainCount for car %d", [myCar retainCount]);
return 0;
}
One thing I have been having trouble with is my retainCount keeps saying I have a retainCount of 1, even though the myCar object has been released, followed by a pool drain.
I even tried putting my NSLog for the Retain Count at the very bottom, right above the return 0; }
Shouldn’t it be a retainCount of 0?
write [pool drain]; again just creates a memory leak.
'preciate any and all help