1

I have one NSMutalbeArray which contains another two array one has string value and another has NSMutableArray of custom object

Custom Class

@interface Message : NSObject<NSCoding>

@property (nonatomic,strong) NSString *strMessgaeID;
@property (nonatomic,strong) NSString *strUserID;
@property (nonatomic,strong) NSString *strToUserID;
@property (nonatomic,strong) NSString *strMessgae;
@property (nonatomic,strong) NSString *strMessageDateTime;

@end

To add objects in array i used this type of code

 NSMutableArray  *arrMessages = [NSMutableArray alloc]init];
 NSPredicate *predicate       = [NSPredicate predicateWithFormat:@"strMessageDateTime contains[c] %@",strConvertedDate];
 NSMutableArray *arrResult    = [[arrSortedMessages filteredArrayUsingPredicate:predicate] mutableCopy];
 arrMessage                   = [@[strDate,arrResult] mutableCopy];
 [arrMessages addObject:arrMessage];

Now to update one object and refresh my UITabeList

    NSString *MSGID = @"4"
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"strMessgaeID == %@", MSGID];
// I have also try following 
//     NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF[1].strMessgaeID == %@", MSGID];
//     NSPredicate *predicate = [NSPredicate predicateWithFormat:@"ANY SELF[1].strMessgaeID == %@", MSGID];

    Message *objMessage    = [[arrMessages filteredArrayUsingPredicate:predicate] firstObject];

    if (objMessage != nil) {
         [arrMessages replaceObjectAtIndex:index withObject:objMessage];
         [tblMessages reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:index inSection:0]] withRowAnimation:UITableViewRowAnimationFade];
    }

But for any of above ways i am not able to get my custom object to update its value.

Dhaval Dobariya
  • 171
  • 1
  • 12

0 Answers0