• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Allocate memory for object
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Allocate memory for object


  • Subject: Allocate memory for object
  • From: Apirak <email@hidden>
  • Date: Sat, 11 Dec 2004 16:53:24 +0700

Hello,

I try to add two object to myArray by one variable. my source code is look like this

	NSMutableArray *myArray = [[NSMutableArray alloc] init];

	Word *word;

	word = [[Word alloc] init];
	[word setWord:@"test"];
	[myArray addObject:word];

	word = nil;
	word = [[Word alloc] init];
	[word setWord:@"test2"];
	[myArray addObject:word];

	Word *wd = [[myArray objectAtIndex:0] retain];
	NSLog(@"word equal %@", [wd getWord]);

	wd = [[myArray objectAtIndex:1] retain];
	NSLog(@"word equal %@", [wd getWord]);

the result is

word equal test2
word equal test2

but It should be

word equal test
word equal test2

I am java developer, it very hard to deal with vector :(

Apirak Panatkool

e-mail: email@hidden
phone: 01-4033320

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Allocate memory for object
      • From: Jonathan Jackel <email@hidden>
    • Re: Allocate memory for object
      • From: Jonathon Mah <email@hidden>
  • Prev by Date: Re: Kill other process's warning dialog
  • Next by Date: Re: NSMutableArrya problems
  • Previous by thread: Re: NSFileWrapper Directories
  • Next by thread: Re: Allocate memory for object
  • Index(es):
    • Date
    • Thread