remove object from NSMutableArray by key

remove object from NSMutableArray by key

By : Zaki Falimbany
Date : November 18 2020, 01:01 AM
To fix the issue you can do To filter objects out of an NSArray, call filteredArrayUsingPredicate:
code :
NSArray *array = @[@{@"name":@"Jenny",@"age":@23},@{@"name":@"Daisy",@"age":@27}];
NSArray *array2 =
  [array filteredArrayUsingPredicate:
   [NSPredicate predicateWithBlock:^BOOL(id obj, NSDictionary *d) {
      return ![[obj valueForKey:@"age"] isEqual:@27];
let array = [["name":"Jenny", "age":23],["name":"Daisy", "age":27]]
let array2 = array.filter {$0["age"] != 27}

Share : facebook icon twitter icon
how to remove an NSMutableArray object by key?

how to remove an NSMutableArray object by key?

By : user3465572
Date : March 29 2020, 07:55 AM
I wish this helpful for you If you're actually using an array and not a dictionary, you need to search for the item before you can remove it:
code :
NSUInteger index = [data indexOfObjectPassingTest:^BOOL (id obj, NSUInteger idx, BOOL *stop) {
    return [[(NSDictionary *)obj objectForKey:@"Account"] isEqualToString:@"B"];

if (index != NSNotFound) {
    [data removeObjectAtIndex:index];
I can't remove an object from a NSMutableArray

I can't remove an object from a NSMutableArray

By : YesYouPlan
Date : March 29 2020, 07:55 AM
I wish did fix the issue. You cannot remove objects from NSArray, you can remove it only from NSMutableArray
code :
NSLog(@"Array : %@", candidatesProxy);
NSLog(@"Element : %@",[[pseudonymsArrayController selectedObjects] lastObject]);
remove object from NSMutableArray

remove object from NSMutableArray

By : Damon_cw
Date : March 29 2020, 07:55 AM
I wish did fix the issue. You get an exception because you are mutating a container while iterating over its elements.
removeObject: does exactly what you're looking for: removing all objects that are equal to the argument.
code :
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
    if (editingStyle != UITableViewCellEditingStyleDelete)

    NSString *searchString = [self.mruSearchItems objectAtIndex:indexPath.row];
    [self.mruItems removeObject:searchString];
    [self.searchTableView reloadData];
Remove object from NSMutableArray?

Remove object from NSMutableArray?

By : Simon Feriancek
Date : March 29 2020, 07:55 AM
I wish this help you I have an array with following elements in ViewDidLoad method , You can use the following code
code :
for (int i=0;i<[inputArray count]; i++) {
        NSString *item = [inputArray objectAtIndex:i];
        if ([item rangeOfString:s].location == NSNotFound) {
            [inputArray removeObject:item];
Remove selected row index object from NSMutableArray and add to another NSMutableArray

Remove selected row index object from NSMutableArray and add to another NSMutableArray

By : Abhishek
Date : March 29 2020, 07:55 AM
I wish this help you You need to add the object to the second array before removing it from the first. Here's a way to do this with two lines of code:
code :
[_array02 addObject:[_array01 objectAtIndex:indexPath.row]];
[_array01 removeObjectAtIndex:indexPath.row];
id myObject = [_array01 objectAtIndex:indexPath.row];
[myObject setTitle:@"new title"]; // example of modifying the object before moving it
[_array02 addObject:myObject];
[_array01 removeObjectAtIndex:indexPath.row];
Related Posts Related Posts :
  • NSRunLoop API difference
  • Is it possible to inject custom settings into my iOS application "Notifications" settings dialog?
  • UIAlertview not accepting string as message
  • Axis change of stackView giving layout error
  • How to use AVAssetResourceLoader?
  • How to write block definition using properties?
  • iOS connect/reconnect to Bluetooth device when using external-accessory and MFi
  • Saving XMPP Multi User chat messages through XMPP MessageArchiving in iOS
  • Deciding iOS version: pros and cons
  • iOS: Resigned app cannot access keychain through security API
  • How can I set To and Subject fields in an E-Mail being sent by UIDocumentInteractionController?
  • Updating uilabel in view controller underneath another
  • Maximum time Intervel for NSTimer
  • Delete Core Data Entry from Table View Controller
  • How to unload UIViewcontroller from memory?
  • Compressing UIImage as Far as Possible?
  • Optimizing workflow to update internally owned cocoapods dependencies?
  • Formatting an NSDate with Abbreviated Month/Day Names
  • I'm creating a quiz game with 4 answers and I want to add score
  • Tap Gesture to Hide Navigation Bar, Tab Bar, and Status Bar
  • FBSessionStateClosedLoginFailed when I am logged in through Settings
  • CGRect positioning according to center point
  • iOS: Update table view datasource with animations without core data
  • iOS : Where to start for AliPay integration?
  • Routing App Coverage File missing but not needed?
  • Drawing on a zoomable view
  • Append NSStrings and NSNumber to NSMutableArrays and make NSMutable dictionary
  • Terminating app due to uncaught exception 'NSRangeException' when calling dequeueReusableCellWithReuseIdentifier:forInde
  • Collision without physics (Cocos2D + Box2D iOS)
  • Creating a percentage based iOS layout
  • Update tableView row from AppDelegate Swift 4
  • Assigning return value of a class method to a variable error
  • how to display circular progress in delphi ios apps?
  • I can't figure how to fix this Expected identifier or '('
  • How to Test APIs in Swift 4?
  • Link error /Build/Products/Debug-iphonesimulator file not found
  • working with a very large JSON object in iOS
  • Turn off part of the iPhone Screen
  • Phonegap 3.0 app with facebook login using xCode
  • How to add interstitial admob ads to my ios project
  • adding tapku calendar to ios app
  • Add an alertcontroller in a global swift file?
  • Take square image with Cordova (Phonegap) Camera API?
  • Amazon S3 policy allowing only upload not overwrite
  • How to change the UILabel content by tapping?
  • Adding checkmark to selected table cell also checks another table cell
  • UICollectionView cellForItemAtIndexPath indexPath row is nil
  • Resize and set quality on JPEG image while retaining EXIF in iOS
  • How to push rootviewcontroller in Ios
  • How to add UIBarbuttonItem at centre on UInavigationbar in iOS
  • Would this IOS device test crash be expected
  • PickerView not showing any values
  • How to set root view controller in storyboard animated with navigation controller programmatically
  • Can anyone suggest me the effective way to deal with s3 upload fail because of timezone difference issue?
  • Getting list of files in documents folder
  • Error while using Realm Object as a singleton. Is it a good idea?
  • inserting into SQLite database
  • More nodes than I should
  • Facebook IOS SDK navigate to another controller after login not working
  • Swift Array - use "Contains" of type AnyObject
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org