ios - Using JSQMessages framework with Core-data -


this core-data object message:

#import <foundation/foundation.h> #import <coredata/coredata.h>  @class account;  @interface message : nsmanagedobject  @property (nonatomic, retain) nsnumber * read; @property (nonatomic, retain) nsdate * sentdate; @property (nonatomic, retain) nsstring * text; @property (nonatomic, retain) nsstring * receiver; @property (nonatomic, retain) nsstring * sender; @property (nonatomic, retain) account *account;  @end 

then messages viewcontroller, load messages code:

- (void)loadmessages   messages = [[nsmutablearray alloc]initwitharray:_fetchedresultscontroller.fetchedobjects];    //------------------------------------------------------------------------------------------------------------------------------------------------- demo message demo incoming message.  static nsstring *senderid = @"2"; static nsstring *senderdisplayname = @"a";   jsqmessage *message = [[jsqmessage alloc] initwithsenderid:senderid                                          senderdisplayname:senderdisplayname                                                       date:[nsdate distantpast]                                                       text:@"helloloo"];  messages = [[nsmutablearray alloc]initwithobjects:message, nil];  //------------------------------------------------------------------------------------------------------------------------------------------------- demo message demo incoming message. 

now i'm new framework https://github.com/jessesquires/jsqmessagesviewcontroller , went on framework docs , didn't find answer problem is:

can use (nsfetchedresultscontroller) framework? if how can use (nsfetchedresultscontroller) in jsqmessages collectionview datasource in right way , return messages core data?. know how use (nsfetchedresultscontroller) not sure how use collectionview , framework. seem collectionview data source/delegate methods work nsmutablearray , app crashes when staff (nsfetchedresultscontroller).

for example:

return [_fetchedresultscontroller.fetchedobjects objectatindex:indexpath.item]; 

vs:

return messages[indexpath.item];  

when use _fetchedresultscontroller.fetchedobjects app crashes.

so after thinking said ok if convert .fetchedobjects (nsarray) (nsmutablearray) of messages , got stack don't know how right way need help. need way return messages sqlite database app.

i have looked @ parse example https://github.com/relatedcode/realtimechat , here want own code without having pay parse.com , able use core-data.

when call : jsqmessage need how tell return objects in fetch result controller *.fetechedobjects*.


Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -