I am trying to get this code to work but cannot seem to get any output that shows the variables are being set:
#import <Foundation/Foundation.h>
#import "thingy.h"
int main (int argc, const char * argv[])
{
@autoreleasepool {
thingy *mythingy;
[mythingy setMass:75.00];
[mythingy setTime:5.00];
NSLog(@"mass of mythingy = %f kg", [mythingy mass]);
NSLog(@"time of mythingy = %f sec", [mythingy time]);
}
return 0;
}
this is the output i am getting:
mass of mythingy = 0.000000 kg
time of mythingy = 0.000000 sec
I also tried not using the @autoreleasepool (ARC) and the code looks like the following but with the same output as before:
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
thingy *mythingy;
[mythingy setMass:75.00];
[mythingy setTime:5.00];
NSLog(@"mass of mythingy = %f kg", [mythingy mass]);
NSLog(@"time of mythingy = %f sec", [mythingy time]);
[mythingy release];
[pool drain];
UPDATE:
okay so i took the previous code and added a line it looks like this now and works but is frustrating because i want to use ARC!!!!
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
thingy *mythingy = [[thingy alloc]init];
[mythingy setMass:75.00];
[mythingy setTime:5.00];
NSLog(@"mass of mythingy = %f kg", [mythingy mass]);
NSLog(@"time of mythingy = %f sec", [mythingy time]);
[mythingy release];
[pool drain];
Output of this code:
mass of mythingy = 75.000000 kg
time of mythingy = 5.000000 sec