design question
design question
- Subject: design question
- From: Ariel Feinerman <email@hidden>
- Date: Tue, 22 Mar 2011 21:29:36 +0200
Hi,
can someone look at and say is a returning of immutable objects necessary or
no?
@interface XMLElement : NSObject {
NSString *_name;
NSMutableString *_text;
NSMutableDictionary *_attributes;
NSMutableArray *_children;
XMLElement *_parent;
}
@implementation XMLElement
- (NSArray *) elementsForName: (NSString *) name {
NSMutableArray *children = [NSMutableArray new];
for (XMLElement *element in _children)
if ([[element name] isEqualToString: name])
[children addObject: element];
NSArray *lchildren = [children copy];
[children release];
return [lchildren autorelease];
}
- (void) setChildren: (NSArray *) children {
[_children release];
_children = [children mutableCopy];
}
- (NSArray *) children {
return [[_children copy] autorelease];
}
- (NSString *) XMLString {
return [[[self _XMLString] copy] autorelease];
}
//
@end
--
best regards
Ariel
_______________________________________________
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