{"action":"closed","issue":{"url":"https://api.github.com/repos/jessesquires/JSQMessagesViewController/issues/954","labels_url":"https://api.github.com/repos/jessesquires/JSQMessagesViewController/issues/954/labels{/name}","comments_url":"https://api.github.com/repos/jessesquires/JSQMessagesViewController/issues/954/comments","events_url":"https://api.github.com/repos/jessesquires/JSQMessagesViewController/issues/954/events","html_url":"https://github.com/jessesquires/JSQMessagesViewController/issues/954","id":71334868,"number":954,"title":"Incoming message with NSFetchedResultsController","user":{"login":"Djoz2","id":11998529,"avatar_url":"https://avatars.githubusercontent.com/u/11998529?v=3","gravatar_id":"","url":"https://api.github.com/users/Djoz2","html_url":"https://github.com/Djoz2","followers_url":"https://api.github.com/users/Djoz2/followers","following_url":"https://api.github.com/users/Djoz2/following{/other_user}","gists_url":"https://api.github.com/users/Djoz2/gists{/gist_id}","starred_url":"https://api.github.com/users/Djoz2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Djoz2/subscriptions","organizations_url":"https://api.github.com/users/Djoz2/orgs","repos_url":"https://api.github.com/users/Djoz2/repos","events_url":"https://api.github.com/users/Djoz2/events{/privacy}","received_events_url":"https://api.github.com/users/Djoz2/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/jessesquires/JSQMessagesViewController/labels/questions%20&%20help","name":"questions & help","color":"bfdadc"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-27T16:22:56Z","updated_at":"2015-05-04T23:27:52Z","closed_at":"2015-05-04T23:27:52Z","body":"\r\nHey @jessesquires , i'm trying now for the past week to use you're library with Core-Data.\r\n\r\nMy Message Class for Core-Data is looking like this:\r\n\r\n@interface Message : NSManagedObject\r\n@property (nonatomic, retain) NSNumber * read;\r\n@property (nonatomic, retain) NSString * receiver;\r\n@property (nonatomic, retain) NSString * sender;\r\n@property (nonatomic, retain) NSDate * date;\r\n@property (nonatomic, retain) NSString * text;\r\n@property (nonatomic, retain) NSNumber * messageHash;\r\n@property (nonatomic, retain) NSString *senderId;\r\n\r\nOK now for the problem:\r\n\r\nFirst of all let me show you the why I use NSFetchedResultsController:\r\n\r\n- (NSFetchedResultsController *)fetchedResultsController {\r\n NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];\r\n    NSEntityDescription *entity = [NSEntityDescription entityForName:@\"Message\" inManagedObjectContext:_managedObjectContext];\r\n    [fetchRequest setEntity:entity];\r\n NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@\"date\"\r\n                                                                   ascending:YES];\r\n    [fetchRequest setSortDescriptors:[NSArray arrayWithObjects:sortDescriptor, nil]];\r\n\r\nSo when I send message to \"User 1\" and when I'm \"User 2\" I can see all incoming and outgoing message just fine, but If I'm \"User 3\" I can see all the same messages that \"User 1\" sent to \"User 2\".\r\n\r\nThe result:\r\n\r\nhttp://s13.postimg.org/fe8gp0phz/Screen_Shot_2015_04_27_at_19_06_06.png\r\nhttp://s29.postimg.org/ub4ulde93/i_OS_Simulator_Screen_Shot_Apr_27_2015_19_04_17.png\r\nhttp://s28.postimg.org/l10g6oi0t/i_OS_Simulator_Screen_Shot_Apr_27_2015_19_04_23.png\r\nhttp://s12.postimg.org/9etsq1tkt/Screen_Shot_2015_04_27_at_19_07_14.png\r\n\r\nFor that I just added a predicate to my fetch results right? so now its looking like this:\r\n\r\n NSPredicate *predicate = [NSPredicate predicateWithFormat:@\"sender = %@ and receiver = %@\", user_email, receiver ];\r\n[fetchRequest setPredicate:predicate];\r\n\r\n\r\nBut now I can only see the outgoing messages because the predicate find only the same user as the predicate code say's. \r\n\r\nSo the result now is just outgoing messages:\r\n\r\nhttp://s28.postimg.org/fhaxsr22l/i_OS_Simulator_Screen_Shot_Apr_27_2015_19_13_21.png\r\n\r\n\r\nSo for trying to fix this what I did is just some helper code:\r\n for incoming messages I added a little helper code which just check incoming message or outgoing message And then called this in the bubble messages data source delegate:\r\n- (BOOL)incoming:(Message *)message\r\n{\r\n    return ([message.senderId isEqualToString:self.senderId] == NO);\r\n}\r\n- (BOOL)outgoing:(Message *)message\r\n{\r\n    \r\n    return ([message.senderId isEqualToString:self.senderId] == YES);\r\n}\r\n\r\nBut still its not working!\r\n\r\n\r\n1) Is it good to use Core-Data for messages app?\r\n2) https://github.com/jessesquires/JSQDataSourcesKit  I saw you made this code for NSFetchedResultsController, but my problem is that it's in .swift does it have something to do with my problem?\r\n3) I understand my problem which is the JSQ is handling the sender id incoming outgoing messages but I don't know how to fix it.\r\n\r\n4)Do you please have some code example with Core-Data for this framework?\r\n\r\n5)How can I fix this and show the user is messages and not all message or just outgoing messages?\r\n\r\n@jessesquires  please help me I'm getting crazy already from this issue.\r\n@jessesquires  I went all over the docs and saw the senderId is a unique key for the user who send the message... you should really give more info on how to use this.\r\nand there should be something such as sender receiver ID or just string for the Receiver who should receive the message. Thank you from advance and thank you for this great library. "}}