I have created a simple program that has a Photo class with these two instance variables
caption, photographer.
The following is the code.
photo.h
Code:
@interface Photo : NSObject {
NSString * caption;
NSString * photographer;
}
@property (retain) NSString * caption;
@property (retain) NSString * photographer;
@end
photo.m
Code:
@implementation Photo
@synthesize caption;
@synthesize photographer;
- (void) dealloc {
[caption release];
[photographer release];
[super dealloc];
}
@end
main.m
Code:
#import "Photo.h"
@implementation main
int main (int argc, char *argv[]) {
Photo *obj = [[Photo alloc]init];
obj.caption = "Evening";
obj.photographer = "Hari";
NSLog([obj caption]);
NSLog([obj photographer]);
[obj dealloc];
}
@end
When I build and run, I get the following output.
Code:
2011-02-22 11:56:03 test_1[1402:a0f] *** __NSAutoreleaseNoPool(): Object 0x100002078 of class NSCFString autoreleased with no pool in place - just leaking
2011-02-22 11:56:03 test_1[1402:a0f] Evening
2011-02-22 11:56:03 test_1[1402:a0f] *** __NSAutoreleaseNoPool(): Object 0x100002098 of class NSCFString autoreleased with no pool in place - just leaking
2011-02-22 11:56:03 test_1[1402:a0f] Hari
Can someone please explain me why I am getting the two statements other than what I'm printing?