Re: Subclassing a NSMutableArray
Re: Subclassing a NSMutableArray
- Subject: Re: Subclassing a NSMutableArray
- From: Lorenzo <email@hidden>
- Date: Thu, 16 Mar 2006 19:53:49 +0100
Thanks!
Best Regards
--
Lorenzo
email: email@hidden
> From: Ondra Cada <email@hidden>
> Date: Thu, 16 Mar 2006 18:39:39 +0100
> To: Lorenzo <email@hidden>
> Cc: email@hidden
> Subject: Re: Subclassing a NSMutableArray
>
> Oh, by the way, one more suggestion:
>
> On 16.3.2006, at 16:57, Lorenzo wrote:
>
>> - (void)setParam:(int)par to:(float)newValue verbose:(BOOL)verbose
>> {
>> int i, totObjects = [self count];
>> for(i = 0; i < totObjects; i++){
>> id item = [self objectAtIndex:i];
>> [item setParam:par to:newValue verbose:verbose];
>> }
>> }
>
> Don't, unless you have to. Use enumerators instead--they are more
> efficient, cleaner design-wise, and less error-prone from the
> programmer's point of view:
>
> for (id o,en=[self objectEnumerator];o=[en nextObject];)
> [o setParam:par to:newValue verbose:verbose];
>
> Myself, I prefer a handy macro for these cases:
>
> #define forall3(variable,enumerator,enumerable) for (id
> variable,enumerator=[enumerable objectEnumerator];(variable=
> [enumerator nextObject]);)
> #define forall(variable,enumerable) forall3
> (variable,_OCS_OCS_OCS_internal_enumerator_,enumerable)
>
> then it looks like
>
> forall (o,self) [o ....];
> ---
> Ondra Čada
> OCSoftware: email@hidden http://www.ocs.cz
> private email@hidden http://www.ocs.cz/oc
>
>
_______________________________________________
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