objective c - count elements inside id<NSFastEnumeration> -
A I id & lt; NSFastEnumeration & gt;
is the object I want to count the elements inside the object. How can this be achieved?
The only way NSFastEnumeration tools:
- (NSUInteger) countByEnumeratingWithState: (NSFastEnumerationState *) state objects: (id *) stackbuf count: (Ansuintegr) LAN
I see this method count, but as I really do not want to disclose the things which I think, how can I pass safely as a logic. Would it be okay to just go through zero, zero, 0? If not, what should I do?
Background:
I want to make an NSArray the return values of the function I, which I want to call each element given my collection. I want an array of results to calculate the collection of a function
id & lt; NSFastEnumeration & gt; Calculative = some objects; NSMutableArray * result = [NSMutableArray arrayWithCapacity: (# # Fill count on #)]; For (NJ object Anyumretebl) {[results addObject: callFunctionOnObject (object)]; }
As you can see, I need to count to customize only Array Initialization. I am very aware that I NSMutableArray * results = [NSMutableArray array]; I can use
.
The only way to get length from an NSFastEnumeration is through the loop.
int count = 0; (In IDE enumerator) ++ calculation; Calculation of return;
Of course it means that calculator
will end and you can not find it again.
In addition, the ability is just an indication that there is little advantage in setting it up
Comments
Post a Comment