Comments (14)
Delivered in version 4.0.0. See Address
struct.
from swiftlysalesforce.
Spelling mistake in Address.
case block = "Blcok"
from swiftlysalesforce.
@pbrondum -- thanks. I'll fix that shortly; opened issue #44
from swiftlysalesforce.
from swiftlysalesforce.
@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.
@pbrondum I added an example here
from swiftlysalesforce.
No matter how I use your example I get:
Value of type 'Address?' has no member 'longitude'
from swiftlysalesforce.
@pbrondum can you post your code?
from swiftlysalesforce.
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.
@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.
Now I get the following for both assignments:
'longitude' is inaccessible due to 'internal' protection level
from swiftlysalesforce.
@pbrondum sorry again... the member vars should be public
-- I'll fix ASAP.
from swiftlysalesforce.
from swiftlysalesforce.
@pbrondum should be fixed now in version 4.0.3 - Address
members are explicitly public
.
Thanks
from swiftlysalesforce.
Related Issues (20)
- Enhance SOSL to support AnyPublisher<QueryResult<T> HOT 6
- Login not working after dismissed HOT 1
- Question: Best practices for querying if user is allowed to update object HOT 1
- Composite resources support HOT 2
- MyRecords() func assumes object has 'ownerId' column HOT 8
- Login migration path for Swift Apps HOT 6
- Support for Anonymous Apex? HOT 7
- Error in fields array: Protocol 'Encodable' as a type cannot conform to the protocol itself HOT 7
- salesforce.search() replacement? in 9.0 HOT 2
- 'group by' count() soql fails in 9.0 HOT 26
- WebAuthenticator.swift:50:30: 'shared' is unavailable in application extensions for iOS HOT 1
- keyNotFound "id" error on simple query HOT 7
- Query with date predicate fail HOT 8
- Minor doc bug HOT 1
- Is there another way to perform salesforce.nextResultPage in V10? HOT 6
- Update links in README.md so they point to latest code version
- Adding SwiftlySalesforce to new project adds V8.0 (master) HOT 4
- Add ability to save files to SFDC & share via Chatter/Slack
- Implementation in ipad Swift Playground. AuthenticationError HOT 3
- README OATH screenshot needs refresh HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swiftlysalesforce.