1

I have a simple idea, but I am stuck with it. :(

I am using swift and Parse. I want to send a message to a specific user. and I want this message displayed like this... example for the tableviews by sketch

In MSG table view, it should be empty until the users send messages. Then, lists of users that sent messages to this specific user updated with the last message received. In User1 table view, the user name displayed in the navigation controller, and list of user1 messages sorted by the time and date.

How can I achieve that, would you help me please?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Amal Nasir
  • 164
  • 15

1 Answers1

0

Lets say there are two class : A (user list) and B (message list for a user).

Add one public variable say C ( or property of strong type array for data source of messages) for class B

On A When we tap on tableview cell : didSelectRowAtIndexPath make one array object of messages for that user say D, before pushing to B class assign this object to above mention object (B.C = D)

Now use this C in your class to use as datasource for message list table.

You can also refer Passing Data between View Controllers

Community
  • 1
  • 1
Devanshu Saini
  • 765
  • 5
  • 24
  • Ok. but I want the A (user list) empty until a userA send a message. and if userB send a message he goes under userA. when I select userA, it goes to B (message list for a user) showing all his messages. – Amal Nasir Feb 24 '16 at 06:50
  • For Class A (user list) will get updated by socket based connection of any API connection to receive any message from some users then only Class user list will get updated If there is some user list, when we tap on it, we fetch and will move to class B for respective messages Will be great if you show me some code I can help you out in this case ad me on skype: devanshu.saini will get in touch at 9PM IST to help you in coding – Devanshu Saini Feb 24 '16 at 07:21
  • Thank you Devanshu!! I got what you meant. I will try to write some code and show you the result. Wait for that!! :) – Amal Nasir Feb 24 '16 at 18:11
  • thank you so much. I sent you my code in Skype. please check that out. – Amal Nasir Feb 25 '16 at 04:17