Re: NSMutableArrya problems
Re: NSMutableArrya problems
- Subject: Re: NSMutableArrya problems
- From: Larry Fransson <email@hidden>
- Date: Fri, 10 Dec 2004 23:08:35 -0800
On Dec 10, 2004, at 21:40, Apirak wrote:
my -setWord and -getWord work very well, but it will show me an error
after I get it from NSMutableArray.
Word *wd = [[myArray objectAtIndex:0] retain];
NSLog(@"word equal %@", [wa getWord]);
I think it because "retains or copies" problems that you said. // my
basic skill is java don't know much about vector :p
In the code you posted, you never defined what "wa" is. Perhaps you
meant to write
NSLog(@"word equal %@", [wd getWord]);
It seems like that should work.
Another helpful tip:
- (void) setWord:(NSString *)newword {
word = newword;
}
That will leak memory every time you call it. It should be written
more like this:
- (void)setWord:(NSString *)newWord
{
[newWord retain];
[word release];
word = newWord;
}
You must release the old object before assigning a new one.
Larry Fransson
Seattle, WA
_______________________________________________
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