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

Can't show Double from CoreData in UILabel inside a TableViewCell
How to add the libxml framework in the iOS application?
“Array index out of range” when choosing photos in Swift
How to register GADNativeAd to auto handle GADNativeContentAd view click in iOS?
gen_bridge_support ignores variadic functions
UISlider default thumbcolor
Olympus Camera Kit: Cannot update exposure compensation value soon after
Trigger an event (tableview reload) whenever a text is in a certain position of a textView in iOS
Populating a UITableView within a UIViewController and changing data source with UISegmentedControl
can't access webView from UiViewController subViews
What is the current Parse email verification regex pattern?
How to send images and videos to server using ASHTTPRequest in ios
how to rearrange array using objective c?
swift - Twitter login button created with no completion block?
AVAnimator Assertion failure in -[AVMvidFrameDecoder advanceToFrame:] 'framebuffer num bytes'
Instagram InstagramCaption not working

Categories

HOME
uwp
mocking
redirect
load
tcl
react-navigation
design
xcode8
spi
jbpm
microsoft-dynamics
asp.net-mvc-3
ceph
struts2-jquery
copy-paste
uwsgi
signature
asp.net-mvc-5.2
monaco-editor
factory-girl
afnetworking-2
jquery-selectors
silk-performer
stm32f4discovery
jmeter-plugins
man
php-carbon
dsl
ucwa
x-sendfile
debugview
charts.js
mobilefirst-bluemix
haxm
executorservice
jetty-9
qweb
bem
windows-scripting
protobuf-3
dxgi
integer-programming
simplesamlphp
android-identifiers
findall
informatica-cloud
error-correction
webtrends
kernighan-and-ritchie
4d
sql-server-2016-express
ios-frameworks
isapi-rewrite
membership
dual-table
greenfoot
laravel-forge
delphi-10-seattle
spl
rdotnet
pyenchant
realm-list
cvc4
size-t
swift-array
simpleadapter
android-tablelayout
tortoisecvs
cvs2git
mysql5
sqlhelper
gdk
sendto
custom-titlebar
bson
windows-phone-7.1
delphi-2009
qdebug
godaddy-api
layout-manager
eject
xsocket
oncreate
arden-syntax
tipsy
jammit
retain
custom-tag
nsindexset
xoom
excel-web-query
custom-protocol
xml-database
drupal-gmap
utility
cracker
iphone-sdk-3.1
resharper-4.5
docking

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