次のようにXcodeで文字列を作成しました:
@property (nonatomic, retain) NSString *lati;
私も合成しました…
今私のviewLoadで、この関数でLAtitudeを取得します:
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation {
int degrees = newLocation.coordinate.latitude;
double decimal = fabs(newLocation.coordinate.latitude - degrees);
int minutes = decimal * 60;
double seconds = decimal * 3600 - minutes * 60;
lati = [NSString stringWithFormat:@"%d° %d' %1.4f\"",
degrees, minutes, seconds];
//latLabel.text = lat;
degrees = newLocation.coordinate.longitude;
decimal = fabs(newLocation.coordinate.longitude - degrees);
minutes = decimal * 60;
seconds = decimal * 3600 - minutes * 60;
longi = [NSString stringWithFormat:@"%d° %d' %1.4f\"",
degrees, minutes, seconds];
}
後で、いくつかの文字列を slite3 データベースに保存したいのですが、Lati 文字列が適切に設定されていないため、Bad_Access が発生しますが、理由がわかりません...これが私の SaveToDB メソッドです:
if (sqlite3_open([dbPath UTF8String], &db) == SQLITE_OK) {
NSString *insertSQL = [NSString stringWithFormat:@"INSERT INTO DATEN(download, upload, ping, comment, date, network, latitude, longitude) VALUES (\"%@\", \"%@\", \"%@\",\"%@\", \"%@\",\"%@\", \"%@\",\"%@\")",topDownloadLabel.text, topUploadLabel.text, pingLabel.text, Comment, string, WlanOrUmts, lati, longi];
そして、Bad_Access を取得します。