[TxMt] An alternate stracc (objc bundle) implementation snippet

Mark Grimes mark at stateful.net
Wed Apr 12 21:37:25 UTC 2006


I'm not groking the current implementation of stracc in the objc bundle.

- (NSString *)${1:thing}
{
	return ${2:f${1/(.)(.*)/\U$1\E$2/}};
}

- (void)set${3:${1/(.)(.*)/\U$1\E$2/}}:(NSString *) $1
{
	NSString * old${3:Thing} = ${2:fThing};
	$2 = [${1:thing} copy];
	[old${3:Thing} release];
}

Clearly fThing is not defined so return fThing makes no sense in a  
getter accessor method.  Nor does instantiating another string object  
in the setter method.

A "working" objc stracc:

- (NSString *)${1:thing}
{
	return ${2:${1/(.)(.*)/$1\E$2/}};
}

- (void)set${3:${1/(.)(.*)/\U$1\E$2/}}:(NSString *)${4:a$3}
{
	$4 = [$4 copy];
	[$1 release];
	$1 = $4;
}

[This models the string accessor implementation defined in  
Hillegass ... if it's not correct, maybe someone should tell Aaron.]

Refactoring and/or explanation as to the current defined stracc is  
welcome/encouraged.

--
Mark Grimes
Stateful Labs
mark at stateful.net


-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
URL: <http://lists.macromates.com/textmate/attachments/20060412/6c39a44d/attachment.sig>


More information about the textmate mailing list