• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Subclassing a NSMutableArray
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Subclassing a NSMutableArray


  • Subject: Re: Subclassing a NSMutableArray
  • From: Ondra Cada <email@hidden>
  • Date: Thu, 16 Mar 2006 18:39:39 +0100

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
  • Follow-Ups:
    • Re: Subclassing a NSMutableArray
      • From: Lorenzo <email@hidden>
References: 
 >Subclassing a NSMutableArray (From: Lorenzo <email@hidden>)

  • Prev by Date: Re: Subclassing a NSMutableArray
  • Next by Date: CoreData app random crash on startup
  • Previous by thread: Re: Subclassing a NSMutableArray
  • Next by thread: Re: Subclassing a NSMutableArray
  • Index(es):
    • Date
    • Thread