Git Product home page Git Product logo

Comments (14)

mike4aday avatar mike4aday commented on June 5, 2024

Delivered in version 4.0.0. See Address struct.

from swiftlysalesforce.

 avatar commented on June 5, 2024

Spelling mistake in Address.

case block = "Blcok"

from swiftlysalesforce.

mike4aday avatar mike4aday commented on June 5, 2024

@pbrondum -- thanks. I'll fix that shortly; opened issue #44

from swiftlysalesforce.

 avatar commented on June 5, 2024

from swiftlysalesforce.

mike4aday avatar mike4aday commented on June 5, 2024

@pbrondum do you see the latitude and longitude values in the Salesforce UI or via Workbench - the clean rules can take time? Also It looks like your map function is getting the record "root," rather than the Address JSON. Argument should be $0.address(for: "ShippingAddress")

from swiftlysalesforce.

mike4aday avatar mike4aday commented on June 5, 2024

@pbrondum I added an example here

from swiftlysalesforce.

 avatar commented on June 5, 2024

No matter how I use your example I get:
Value of type 'Address?' has no member 'longitude'

from swiftlysalesforce.

mike4aday avatar mike4aday commented on June 5, 2024

@pbrondum can you post your code?

from swiftlysalesforce.

 avatar commented on June 5, 2024

import UIKit
import MapKit
import SwiftlySalesforce
import PromiseKit

final class MasterViewController: UITableViewController {
var locManager = CLLocationManager()
var currentLocation: CLLocation!

override func viewDidLoad() {
	super.viewDidLoad()
	refreshControl?.addTarget(self, action: #selector(MasterViewController.handleRefresh), for: UIControlEvents.valueChanged)
    locManager.requestWhenInUseAuthorization()
    
    if (CLLocationManager.authorizationStatus() == CLAuthorizationStatus.authorizedWhenInUse ||
        CLLocationManager.authorizationStatus() == CLAuthorizationStatus.authorizedAlways){
        currentLocation = locManager.location
        print("Curr Lat: \(currentLocation.coordinate.latitude)")
        print("Curr Long: \(currentLocation.coordinate.longitude)")
        print(currentLocation)
    }
    
    first {
        salesforce.retrieve(type: "Account", id: "00130000007dp2SAAQ")
    }.then {
        record in
        let address = record.address(for: "BillingAddress")
        let longitude = address.longitude
        let latitude = address.latitude
        let AccountLocation = CLLocation(latitude: latitude, longitude: longitude)
        let distanceFromCurrentLocation = self.currentLocation.distance(from: AccountLocation) // in meters
        print("Distance in Meters : \(distanceFromCurrentLocation)")
    }.always {
        print("Got here")
    }
    loadData(refresh: true)
}

override func viewWillAppear(_ animated: Bool) {
	super.viewWillAppear(animated)
	//loadData(refresh: false)
}

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
	if let destinationVC = segue.destination as? DetailViewController,
		let cell = sender as? UITableViewCell,
		let indexPath = tableView.indexPath(for: cell),
		let task = TaskStore.shared.cache?[indexPath.row] {
		destinationVC.task = task
		destinationVC.title = task.subject ?? ""
	}
}

from swiftlysalesforce.

mike4aday avatar mike4aday commented on June 5, 2024

@pbrondum sorry, record.address(for: "BillingAddress") returns an optional address, i.e. Address?.

I updated the example code in the README. It now reads:

record in
if let address = record.address(for: "BillingAddress") {
    let longitude = address.longitude
    let latitude = address.latitude
    // You could put a marker on a map...
}

Does that work?

from swiftlysalesforce.

 avatar commented on June 5, 2024

Now I get the following for both assignments:
'longitude' is inaccessible due to 'internal' protection level

from swiftlysalesforce.

mike4aday avatar mike4aday commented on June 5, 2024

@pbrondum sorry again... the member vars should be public -- I'll fix ASAP.

from swiftlysalesforce.

 avatar commented on June 5, 2024

from swiftlysalesforce.

mike4aday avatar mike4aday commented on June 5, 2024

@pbrondum should be fixed now in version 4.0.3 - Address members are explicitly public.
Thanks

from swiftlysalesforce.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.