Problem with allocating memory
Problem with allocating memory
- Subject: Problem with allocating memory
- From: Michael Abendroth <email@hidden>
- Date: Tue, 27 Oct 2009 18:36:01 +0100
Hi everybody,
I wrote this extremely simple program:
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
for (int i = 0; i < 3; i++) {
NSMutableString* myString = [[NSMutableString alloc]
initWithString:[[NSDate date] description]];
NSLog(@"%d", &myString);
}
[pool drain];
return 0;
}
When I run it, the program outputs the same number thrice. Why does
this happen? Shouldn't each string object be stored in a different
place in memory?
Thanks for any input,
Mike
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden