last day (20 days later) » 

11:17 AM
0
A: tableview sort by distance swift

HariKrishnan.Pvar yourarray : [location] = [] yourarray.sort({ $0.distance > $1.distance }) // Function to calculate the distance from given location. func calculateDistance(fromLocation: CLLocation?) { let location = CLLocation(latitude: self.lat, longitude: self.lng) distance = location.distanceF...

 
I use your method but still can't comply, can u be more specific? thank you.
 
your are not able to compare the distance?
 
I have no idea how to get distance from two CLLocationCooridinate2D
 
you have a location array?
 
yes! And it looks like this: let tripspot = [ tripSpot( title: "一中商圈", coordinate: CLLocationCoordinate2DMake(24.149062, 120.684891), regionRadius: 300.0, location: "台中市北區一中街", type: "Food")]
 
11:17 AM
just add that array in you question
 
thank you for helping me
let tripspot = [
tripSpot( title: "一中商圈", coordinate: CLLocationCoordinate2DMake(24.149062, 120.684891), regionRadius: 300.0, location: "台中市北區一中街", type: "Food"),
tripSpot( title: "逢甲夜市", coordinate: CLLocationCoordinate2DMake(24.180407, 120.645086), regionRadius: 300.0, location:"台中逢甲", type: "Food"),
tripSpot( title: "東海商圈", coordinate: CLLocationCoordinate2DMake(24.181143, 120.593158), regionRadius: 300.0, location: "東海商圈", type: "Food"),
tripSpot( title: "第二市場", coordinate: CLLocationCoordinate2DMake(24.14289,120.679901), regionRadius:150.0, location:"400台灣台中市中區第二市場(三民路)",type: "Food"),
 
it ok
 
this is my array looks like
in fact I'm making a Geo targeting to listening people who walk through some specific place
 
11:23 AM
mmm..
wait a sec
 
and hope make tableview to sort from closest to the most far one
OK
I really appreciate that you are willing to help, not many people using swift in our country
I have no one to discuss
 
11:53 AM
hi! are u still there?
 
12:04 PM
s
 
Ok! is that possible to make it?
Or you need more information>
?
 
no i will do it and ping you
 
thanks!
 
 
2 hours later…
2:16 PM
hi
final class Places {
var title: String?
var coordinate: CLLocation
var regionRadius: Double
var location: String?
var type: String?
var distance : Double?

init(title:String , coordinate: CLLocation , regionRadius: Double, location: String, type: String ,distance:Double!){
self.title = title
self.coordinate = coordinate
self.regionRadius = regionRadius
self.location = location
self.type = type
self.distance = distance
}


// Function to calculate the distance from given location.
func calculateDistance(fromLocation: CLLocation?) {
 
Thank u
so fromLocation can be user location?
import UIKit
import Firebase
import MapKit


class mapTableViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate, UITableViewDelegate,UITableViewDataSource,UISearchResultsUpdating{


let tripspot = [
tripSpot( title: "一中商圈", coordinate: CLLocationCoordinate2DMake(24.149062, 120.684891), regionRadius: 300.0, location: "台中市北區一中街", type: "Food"),
tripSpot( title: "逢甲夜市", coordinate: CLLocationCoordinate2DMake(24.180407, 120.645086), regionRadius: 300.0, location:"台中逢甲", type: "Food"),
Instance member 'fromLocation' cannot be used on type 'mapTableViewController'
is that possible just turn CLLocation2Dcoordinate into Cllocation and using distanceFromLocation()?
 
 
2 hours later…
4:02 PM
hi
 
 
1 hour later…
5:22 PM
thank you!! Really appreciate ur time and kindly answer!
 
welcome brother
johnny
 
words can't present how appreciate Im
 
no problem johnny
its my pleasure nad its my passion
your location
?
are you free now?
 
taiwan
I live in taiwan
and trying to make a app
Yes I'm still coding
Im trying to solve the firebase problem
I sent mail to ask firebase team
but they just no reply
 
what is the problem in firebase
 
5:35 PM
Im try to make a social media
 
like a social media
right
?
 
right
but
it stuck when i trying to get the image back from storage
Did you get some data in this line: myPost.userPhoto = UIImage(data: data!) ? Is data empty or nil? — Prcela Jul 5 at 15:27
Did you get some data in this line: myPost.userPhoto = UIImage(data: data!) ? Is data empty or nil? — Prcela Jul 5 at 15:27
 
your not able to get the image from firebase right
?
 
yes!
but it only happen when it is in array
 
please paste the array
your looking nice boy
 
5:38 PM
import UIKit
import Firebase
import FirebaseStorage

class timelineTableViewController: UITableViewController {
var posts = [Post]()
var databaseRef: FIRDatabaseReference!
var storageRef: FIRStorageReference!

override func viewDidLoad() {
super.viewDidLoad()
databaseRef = FIRDatabase.database().reference()
storageRef = FIRStorage.storage().reference()
let userPostRef = self.databaseRef.child("posts")
userPostRef.queryOrderedByChild("time").observeEventType(.ChildAdded, withBlock: {(snapshot) in
struct Post {
var username: String?
var postText: String?
var time: String?
var userPhoto: UIImage?
var postPhoto: UIImage?
var url: String?
var userPhotoUrl:String?
init(data: NSDictionary) {
username = data["username"] as? String
postText = data["postText"] as? String
time = data["time"]as? String
userPhoto = data["userPhoto"] as? UIImage
postPhoto = data["postPhoto"] as? UIImage
url = data["postPhoto"] as? String
userPhotoUrl = data["userPhoto"] as? String
}

}
the issue is likely that the cell is being returned before the photo has finished downloading, and thus doesn't show up
Ha ha my photo are just fat anime
 
show any image
screen shot
 
?
my code?
 
your not able get only image or other details?
 
or app's actually look like
only image
other detail are working great
/Users/johnnyhsieh/Desktop/螢幕快照 2016-07-09 上午1.42.42.png
post just can't fully get back
 
can you try to store it in data. replace the UIimage value
userPhoto = data["userPhoto"] as? UIImage
first check that its work or not?
 
5:45 PM
Ok
i success upload
and down load it back
but the data['userphoto'] are nil
let userPhoto = UIImage(data: data!)!
print(userPhoto.description)
nil
 
are you store in the firebase database storage
 
i store it on the storage
and save the URL at
database
 
check the URL first
 
URL correct
sorry my mistake
let userPhoto = UIImage(data: data!)!
print(userPhoto.description)
correct
cell.postPhoto.image = self.posts[indexPath.row].postPhoto
nil
image do get back
but not pass into the post array
 
i think you not convert the data to UIIMage
let image : UIImage = UIImage(data: imageData)
your are store it as a uiImage
check that may its work
 
5:54 PM
sorry I don't get it
where should i place this code?
do u means that let userPhoto = UIImage(data: data!)!
convert the data to UIImage than data?
 
FIRStorage.storage().referenceForURL(url).dataWithMaxSize(10 * 1024 * 1024, completion: { (data, error) in
let postPhoto = UIImage(data: data!)

})
FIRStorage.storage().referenceForURL(userPhotoUrl).dataWithMaxSize(10 * 1024 * 1024, completion: { (data, error) in
let userPhoto = UIImage(data: data!)
})
print the data
and error
 
<UIImage: 0x7f9f1c0f24e0> size {638, 426} orientation 0 scale 1.000000
I print the userPhoto
and it show like that
so i means the photo do came back right?
 
and something wrong when it append to the array
the firebase guy told me its a main thread
 
s ofcourse
print the array value
check the each and every object
 
6:06 PM
It looks like the issue here is that your post never gets the photo information, due to the fact that those photos are being downloaded asynchronously.

Using pseudocode, what you're doing is:

Get information from database
Create post object
Begin downloading post photo
Populate post object with post photo
Begin downloading user photo
Populate post object with user photo
Return post object
What is happening is that the post object is being returned before the photos have downloaded (since the dataWithMaxSize:completion: call is asynchronous). What you need to end up doing is something that
thats what he say
i print the snapshot.value.description
and
every thing back just right
the the image still the url.reference
do you want to run my apps?
it might help to realize whats going on
all the function works
but when it come to the get the image back
the image seems never pass to the array
and fully show on the tableview
 
yeah sure
send it
 
6:44 PM
email and password
 
OK
jmylife@yahoo.com.tw
password
appwork2016
this is our test account
 
7:08 PM
hey! HariKrishnan its 3 am in Taiwan
Im going to sleep
thank u for everything
I learn a lot from U
 
7:56 PM
hi
i have done
0
A: Retrieve image from firebase storage to show on tableView (Swift)

HariKrishnan.PJust change the below methods func downloadPost(){ let userPostRef = self.databaseRef.child("posts") userPostRef.queryOrderedByChild("time").observeEventType(.ChildAdded, withBlock: {(snapshot) in if let postAdd = snapshot.value as? NSDictionary { print("\(snapshot...

check the answer johnny
bye good ni8. now the time is 1.40 AM in chennai.
meet you tomorrow
 

  last day (20 days later) »