请帮我解决这个内存泄漏问题.在泄漏工具它示出了泄漏:NSCFString(32个字节)在库Foundation负责框架:NSPropertyListSerialization.我发布错误但仍然是泄漏.我错过了什么?非常感谢!
    NSPropertyListFormat format; 
    NSString *anError = nil;
    id plist;
    plist = [NSPropertyListSerialization propertyListFromData:rawCourseArray mutabilityOption:NSPropertyListImmutable format:&format errorDescription:&anError];
    if (!plist){
          [anError release];
    } 
    NSArray *entries = (NSArray *)plist;
    for (NSDictionary *entry in entries) 
    {
      // DO SOMETHING
    }
Run Code Online (Sandbox Code Playgroud) 我试图截取我的应用程序的屏幕截图,然后将其发送给消息中的联系人.当我在我的照片库中查看屏幕截图时,截图很正常...但是当消息编辑器打开图像时,它会显示为"?" 像mime类型不正确.我正在使用UIImageJPEGRepresentation将图像转换为NSData.我究竟做错了什么?非常感谢
func screenShotMethod() {
    if (messageComposer.canSendText()) {
        // Obtain a configured MFMessageComposeViewController
         //Create the UIImage
        UIGraphicsBeginImageContext(view.frame.size)
        view.layer.renderInContext(UIGraphicsGetCurrentContext())
        let image = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()
        //Save it to the camera roll
        //UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil)
        let messageComposeVC = messageComposer.configuredMessageComposeViewController()
        //messageComposeVC.body = image
        var imageData = UIImageJPEGRepresentation(image, 1.0)
        messageComposeVC.addAttachmentData(imageData, typeIdentifier: "image/jpeg", filename: "My Image")
        presentViewController(messageComposeVC, animated: true, completion: nil)
    }
    else
    {
        println("No good")
    }
}
Run Code Online (Sandbox Code Playgroud) 将此系列Objective C代码转换为Swift时遇到问题
for (id <MKAnnotation> annotation in mapView.annotations) {
    // Do Something
}
Run Code Online (Sandbox Code Playgroud)
当我尝试:
for (annotation:MKannotation in mapView.annotations)
Run Code Online (Sandbox Code Playgroud)
要么
for (annotation in mapView.annotations)
Run Code Online (Sandbox Code Playgroud)
我明白了:'期待';' 在'for'声明中
谢谢!!
我有我的MKMapViewDelegate.也,MapView.delegate = self
let c1 = myCLLocationCoodinate
let c2 = myCLLocationCoodinate2
var a = [c1, c2]
var polyline = MKPolyline(coordinates: &a, count: a.count)
self.MapView.addOverlay(polyline)
Run Code Online (Sandbox Code Playgroud)
使用此委托方法:
func mapView(mapView: MKMapView!, rendererForOverlay overlay: MKOverlay!) -> MKOverlayRenderer! {
    if overlay is MKPolyline {
        var polylineRenderer = MKPolylineRenderer(overlay: overlay)
        polylineRenderer.strokeColor = UIColor.whiteColor()
        polylineRenderer.lineWidth = 2 
        return polylineRenderer
    }
    return nil
}
Run Code Online (Sandbox Code Playgroud)
我明白了:EXC BAD ACCESS线程8开启了
self.MapView.addOverlay(polyline)
Run Code Online (Sandbox Code Playgroud) swift ×3
ios ×2
objective-c ×2
memory-leaks ×1
mfmessagecomposeviewcontroller ×1
mkmapview ×1
mkpolyline ×1
screenshot ×1