ObjFW  Check-in [40f7e8bd2e]

Overview
Comment:OFXMLElement: Retain + autorelease attributes.

-[attributeForName:(namespace:)] now returns the attribute retained and
autoreleased instead of returning an inner pointer.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 40f7e8bd2eabcde59b6ea4d1acfa9ae4d65c1c6e1221a51c189770fadbdaf90d
User & Date: js on 2013-02-12 18:14:23
Other Links: manifest | tags
Context
2013-02-12
18:22
Prefix all ivars with an underscore. check-in: e40729d406 user: js tags: trunk
18:14
OFXMLElement: Retain + autorelease attributes. check-in: 40f7e8bd2e user: js tags: trunk
2013-02-10
16:36
Add a warning about reimplementing -[isEqual:]. check-in: b807b66ccc user: js tags: trunk
Changes

Modified src/OFXMLElement.m from [f052993408] to [5e664c8a15].

836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
{
	OFXMLAttribute **objects = [attributes objects];
	size_t i, count = [attributes count];

	for (i = 0; i < count; i++)
		if (objects[i]->ns == nil &&
		    [objects[i]->name isEqual: attributeName])
			return objects[i];

	return nil;
}

- (OFXMLAttribute*)attributeForName: (OFString*)attributeName
			  namespace: (OFString*)attributeNS
{
	OFXMLAttribute **objects;
	size_t i, count;

	if (attributeNS == nil)
		return [self attributeForName: attributeName];

	objects = [attributes objects];
	count = [attributes count];

	for (i = 0; i < count; i++)
		if ([objects[i]->ns isEqual: attributeNS] &&
		    [objects[i]->name isEqual: attributeName])
			return objects[i];

	return nil;
}

- (void)removeAttributeForName: (OFString*)attributeName
{
	OFXMLAttribute **objects = [attributes objects];







|



















|







836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
{
	OFXMLAttribute **objects = [attributes objects];
	size_t i, count = [attributes count];

	for (i = 0; i < count; i++)
		if (objects[i]->ns == nil &&
		    [objects[i]->name isEqual: attributeName])
			return [[objects[i] retain] autorelease];

	return nil;
}

- (OFXMLAttribute*)attributeForName: (OFString*)attributeName
			  namespace: (OFString*)attributeNS
{
	OFXMLAttribute **objects;
	size_t i, count;

	if (attributeNS == nil)
		return [self attributeForName: attributeName];

	objects = [attributes objects];
	count = [attributes count];

	for (i = 0; i < count; i++)
		if ([objects[i]->ns isEqual: attributeNS] &&
		    [objects[i]->name isEqual: attributeName])
			return [[objects[i] retain] autorelease];

	return nil;
}

- (void)removeAttributeForName: (OFString*)attributeName
{
	OFXMLAttribute **objects = [attributes objects];