Re: Returning structs of NSStrings
Re: Returning structs of NSStrings
- Subject: Re: Returning structs of NSStrings
- From: Michael Becker <email@hidden>
- Date: Thu, 25 Mar 2004 11:26:07 +0100
You use the same string for all fields in the struct: "[xmlContainer
descriptionAtIndex: 0]". I don't know how the xmlContainer works, but I
would be very surprised if it created new objects for every call to
"descriptionAtIndex:", most likely it always returns the same object.
Also, rule #1 for memory management in ObjC/Cocoa - if you don't
allocate, don't release. Where did you perform an allocation?
Okay, sorry, I got it. Besides, the code was typed in Mail.app, so
these zeros were typos, of course it's "[ xmlContainer
descriptionAtIndex:number]" where number goes from 0 through 2.
So thanks for the replies! But my second question still bothers me:
I've noticed that dealing with large structs of NSStrings can get
really annoying ("copying" these structs can only be done via copying
each NSString in them [right?]). So should I make all of these into
classes, providing accessor methods? Or am I missing out on something
again? Should I maybe even mix Objective-C++ into it all?
Sorry for asking question that nobody should answer but myself, but I
am more or less asking for stylistic guidance :-)
Bye,
Michael
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.