FCMutableArray 1.0

FCMutableArray 1.0

TestsTested
LangLanguage Obj-CObjective C
License Custom
ReleasedLast Release Dec 2014

Maintained by Unclaimed.


Downloads

Total41
Week0
Month0

Installs

Apps4
powered by Segment

GitHub

Stars4
Watchers2
Forks0
Issues0
Contributors1
Pull Requests0

Code

Files2
LOCLines of Code 161


  • By
  • Florent Crivello

FCMutableArray is a composite class that behaves in the same way than an NSMutableArray, adding a delegate to it.

The delegate is informed each time an object is added or removed from the array, and is also asked the permission to do so. That makes FCMutableArray a very good candidate to manage object queues.

For example, if you want to manage a queue of UILabels that simply represent an NSString, you can add the NSStrings to your FCMutableArray, and transform them into UILabels with the delegate:

- (BOOL)shouldAddObject:(id)object toArray:(FCMutableArray *)array {
    if ([object isKindOfClass:[NSString class]]) {
        UILabel *myLabel = [[UILabel alloc] init];  
        myLabel.text = object;
        return NO;
    }
}

Performances

As you can see in the sample included in this repository, I consistently find FCMutableArrays to be at least 20~30x slower than a regular NSMutableArray. This is the minimal footprint it adds to your program, with a delegate implementing all the methods, but not doing anything in them. This difference doesn't matter for smal to medium arrays (<500 objects), but FCMutableArray for sure shouldn't be considered for large data handlings.