我有一个包含MKMapView的UIViewController.我通过以下代码在当前位置添加了注释:
import UIKit
import MapKit
class LocationViewController: UIViewController , MKMapViewDelegate ,CLLocationManagerDelegate {
@IBOutlet weak var mapView: MKMapView!
var locationManager: CLLocationManager!
let regionRadius: CLLocationDistance = 1000
var token: dispatch_once_t = 0
override func viewDidLoad() {
super.viewDidLoad()
mapView.delegate = self
locationManager = CLLocationManager()
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.requestWhenInUseAuthorization()
locationManager.startUpdatingLocation()
}
func centerMapOnLocation(location: CLLocation) {
let coordinateRegion = MKCoordinateRegionMakeWithDistance(location.coordinate,
regionRadius * 2.0, regionRadius * 2.0)
mapView.setRegion(coordinateRegion, animated: true)
}
func mapView(mapView: MKMapView, didUpdateUserLocation userLocation: MKUserLocation) {
if ((userLocation.coordinate.latitude != 0.0) && …Run Code Online (Sandbox Code Playgroud) 我试图从文本文件中读取UTF8文本,然后将其中一些文本打印到另一个文件.我正在使用Linux和gcc编译器.这是我正在使用的代码:
#include <stdio.h>
#include <stdlib.h>
int main(){
FILE *fin;
FILE *fout;
int character;
fin=fopen("in.txt", "r");
fout=fopen("out.txt","w");
while((character=fgetc(fin))!=EOF){
putchar(character); // It displays the right character (UTF8) in the terminal
fprintf(fout,"%c ",character); // It displays weird characters in the file
}
fclose(fin);
fclose(fout);
printf("\nFile has been created...\n");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
它现在适用于英文字符.