Saturday, June 1, 2013

NSMutableArray removeObjectsInRange example in Objective C (iOS).


NSMutableArray removeObjectsInRange

Removes from the array each of the objects within a given range.

- (void)removeObjectsInRange:(NSRange)aRange

Parameters
aRange
The range of the objects to remove from the array.

Discussion of [NSMutableArray removeObjectsInRange]
The objects are removed using removeObjectAtIndex:.

NSMutableArray removeObjectsInRange example.
NSLog(@"Length: %i",[rawData length]);
NSLog(@"Range: %i",StartTime*freq-1);
[rawData removeObjectsInRange:NSMakeRange(0, StartTime*freq-1)];

Example of [NSMutableArray removeObjectsInRange].
 NSRange r;
 r.location = 5;
 r.length = [someArray count]-5;

 [someArray removeObjectsInRange:r];

NSMutableArray removeObjectsInRange example.
// Overridden Methods
- (void)replaceObjectsInRange:(NSRange)range withObjectsFromArray:(NSArray
*)otherArray range:(NSRange)otherRange;
{
    [arrayLock lock];
    [embeddedArray removeObjectsInRange:range];
    [self addObjectsFromArray:[otherArray subarrayWithRange:otherRange]];
    [arrayLock unlock];
}

- (void)replaceObjectsInRange:(NSRange)range withObjectsFromArray:(NSArray
*)otherArray;
{
    [arrayLock lock];
    [embeddedArray removeObjectsInRange:range];
    [self addObjectsFromArray:otherArray];
    [arrayLock unlock];
}

End of NSMutableArray removeObjectsInRange example article.