Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Objecive-C – Manipulating two arrays
- NSMutableArray *web = [[NSMutableArray alloc] initWithObjects:@"2",@"3",@"4",nil];
- NSMutableArray *disk = [[NSMutableArray alloc] initWithObjects:@"1",@"2",@"3",nil];
- - (void)minusSet:(NSSet *)otherSet
- NSMutableSet *web = [[NSMutableSet alloc] initWithObjects:@"2",@"3",@"4",nil];
- NSMutableSet *disk = [[NSMutableSet alloc] initWithObjects:@"1",@"2",@"3",nil];
- NSMutableSet * remArray = [[NSMutableSet setWithSet:disk] minusSet:web];
- NSMutableSet * addArray = [[NSMutableSet setWithSet:web] minusSet:disk];
- NSMutableArray * remArray = [NSMutableArray arrayWithArray:disk];
- [remArray removeObjectsInArray:web];
- - (NSArray *) differnceBetween: (NSArray *) array1 and: (NSArray *) array2 {
- NSMutableArray *difference = [[NSMutableArray alloc] init];
- for(id obj in array1) {
- if(![array2 contains:obj]) {
- [differnce addObject:obj];
- }
- }
- return difference;
- }
Add Comment
Please, Sign In to add comment