Tag: clplacemark

无法弄清楚如何使用CLPlacemark正确地在消息正文中embedded我的当前位置

我几天前几乎没有尝试将我目前的位置embedded到我的iPhone上的Message body中,但是我失败了。 我尝试了我所有的想法,但我只有错误 我得到的最后一个错误是 “致命错误:意外地发现零,而解包可选值” 我创build了一个CLPlacemark的对象,我把它作为可选项,这意味着它可能有价值或可能CLPlacemark 。 有什么方法来创build一个消息与我目前的位置? MainMenu文件 import UIKit import Social import MessageUI import Foundation import CoreLocation class MainMenu: UIViewController , MFMessageComposeViewControllerDelegate , UINavigationControllerDelegate , MFMailComposeViewControllerDelegate, CLLocationManagerDelegate { let locationManager = CLLocationManager() func messageComposeViewController(controller: MFMessageComposeViewController, didFinishWithResult result: MessageComposeResult) { } let placeMarks = Location() @IBAction func TapOnEmergency(sender: UIButton) { let textMessageRecipients = ["+123456789"] […]

将CLPlacemark扩展为EXC BAD ACCESS

虽然在这里发现了一个类似的问题,但它并没有提供答案,至less不是针对一般问题。 我的问题是:由于CoreLocation地理编码速度有限,而且我正在开发应用程序的(web-)服务提供了自己的后备地址parsing服务,所以我想使用此自定义地理编码服务以防万一达到Apple的速率限制。 此外,我觉得避免自定义数据types对于由此自定义REST API返回的结果是CLPlacemark的,因此希望使用返回的数据来生成CLPlacemark 。 但是,文档指出CLPlacemark属性(如location, locality, administrativeArea等)是read-only 。 因此,我创build了一个CLPlacemark的子类,将需要的属性合成到我可以访问的私有variables上,即: // interface: (.h) @interface CustomPlacemark : CLPlacemark – (nonnull id)initWithLocation: (nonnull CLLocation *)location locality: (nullable NSString *)locality administrativeArea: (nullable NSString *)adminArea country: (nullable NSString *)country; @end // implementation (.m) @implementation CustomPlacemark @synthesize location = _location; @synthesize locality = _locality; @synthesize country = _country; @synthesize administrativeArea […]