ios


Segue to chat viewcontroller


I have included images to hopefully make this easier to understand. My FirstViewController has a collection view with a list of users from my firebase database.When I click on the users I am segued to a DetailedViewController that has more information about the user that was clicked. Within that viewController, the goal is to click on the compose button and segue to a viewController that allows me to chat with the user, whose profile I clicked on.
I have gotten as far as this for segueing from DetailedViewController to Message user 1.
#IBAction func SendMessage(_ sender: Any) {
performSegue(withIdentifier: "chat", sender: self)
}
I am not sure how to make sure I am sending the particular user I click on a message.
This is how I am passing data from FirstViewController to DetailedViewController.
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "details" {
if let indexPaths = self.CollectionView!.indexPathsForSelectedItems{
let vc = segue.destination as! BookDetailsViewController
let cell = sender as! UICollectionViewCell
let indexPath = self.CollectionView!.indexPath(for: cell)
let post = self.posts[(indexPath?.row)!] as! [String: AnyObject]
let Booked = post["title"] as? String
vc.Booked = Booked
print(indexPath?.row)
} }
One route to take is in your DetailViewController class, or whatever class you have implementing "performSegue(withIdentifier:, sender:)", add this:
override public func prepare(for segue: UIStoryboardSegue, sender: Any?) {
guard segue.identifier == "chat", let dest = segue.destination as? ChatViewController else {
return
}
dest.person = self.person
}
I don't know how you have the person's properties declared but if person is an object, do what I have above, if the it's individual properties, do
dest.name = self.name
dest.number = self.number //etc
prepare(for segue:, sender:) allows you to intercept any segue from that class and set up any variable need before the performSegue(...) executes. Make sure you identify the segue in some way otherwise the code will execute on all segues implemented in the class. In my example I used your segue's identifier.

Related Links

How to Blur effect apply on UIView in iOS?
In IOS how to implement (EULA) when app start first time
How to wait for finish dataTaskWithRequest?
Sequencing sounds with a delay in Swift
iOS 9 searchBar disappears from table header view when UISearchController is active
MFMessageComposeViewController not returning to application after send message ios9
This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes.
Writing a flood-fill method in Swift
Facebook Graph API query for latest album from page
Options for sending data to server/retrying requests in background
xcode, ios, Help Image Freezes, Not Moving
Hidden property cannot be changed within an animation block
MPmoviePlayer going black after updating to IOS 9 ( swift )
Run custom script after iOS app is signed in XCode
Video frames fill only 1/4 of the view - GL
How can I change the image in the detail view to access the master view

Categories

HOME
performance
selenium
logstash
vr
crf
auth0
graylog2
outlook
backand
asana
tsql
android-bluetooth
pyusb
google-adwords
entity
r-caret
socrata
apache-spark-sql
binary-search
windows-10-desktop
h2o
tcplistener
asciidoc
wavelet
eloqua
oracle-ucm
executable
signature
google-cloud-sdk
avr
postgresql-9.5
apex
raspberry-pi2
android-dialogfragment
teraterm
graphcool
gitlab-ci-runner
atg
deadbolt
rgdal
datamatrix
csom
google-oauth2
phonegap-desktop-app
meanjs
apscheduler
coqide
android-imageview
python-behave
pymysql
concurrenthashmap
kubernetes-go-client
toastr
petrel
draggable
confirm
packaging
jupyter-irkernel
linechart
drupal-webform
jsonstore
polymer-cli
textangular
botkit
powerpc
autofocus
default-browser
strip-tags
rating-system
jquery-masonry
jawr
webloadui
assembly-references
mapr
kie-workbench
cabal-install
informatica-cloud
mailcore2
android-chips
ckcontainer
ellipsis
activemodel
groups
pypyodbc
jongo
ctakes
cucumber-java
xirr
json4s
selectsinglenode
treegrid
stringr
antiforgerytoken
nolio
asf
iphone-privateapi
controlsfx
nitrogen
master-theorem
modalpopupextender
qt4.7
notifyicon
xidel
llblgenpro
ioerror
tempo
icon-fonts
shebang
sender
pixelsense
vote
51degrees
google-website-optimizer
cellid
ssao
mkmapviewdelegate
remote-control
time-estimation
msn-messenger
iequalitycomparer
web-based
shareware

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App