Iphone sqlite3_exe()中的错误
先生,我正在使用db connectivity,我已经编写了所有代码,并且还导入了头文件。但是在架构中找不到sqlite3_exe符号行中显示的错误 帮我清除Iphone sqlite3_exe()中的错误,iphone,Iphone,先生,我正在使用db connectivity,我已经编写了所有代码,并且还导入了头文件。但是在架构中找不到sqlite3_exe符号行中显示的错误 帮我清除 NSFileManager *filemgr=[NSFileManager defaultManager]; if ([filemgr fileExistsAtPath:databasePath]==NO) { const char *dbpath=[databasePath UTF8String]; if (sqlit
NSFileManager *filemgr=[NSFileManager defaultManager];
if ([filemgr fileExistsAtPath:databasePath]==NO)
{
const char *dbpath=[databasePath UTF8String];
if (sqlite3_open(dbpath, &contactDB)==SQLITE_OK)
{
char *errorMsg;
const char *sql_stmt="CREATE TABLE IF NOT EXISTS CONTACTS (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT, ADDRESS TEXT, PHONE NUMERIC)";
if (sqlite3_exe(contactDB, sql_stmt, NULL,NULL, &errorMsg)!=SQLITE_OK)
{
status.text=@"Failed to crate table";
}
sqlite3_close(contactDB);
}else {
status.text=@"Faild to open/create database";
}
}
错误行是
if (sqlite3_exe(contactDB, sql_stmt, NULL,NULL, &errorMsg)!=SQLITE_OK)
警告:c99中函数“sqlite3_exe”的隐式声明无效。
错误为架构i386的未定义符号:
"_sqlite3_exe", referenced from:
-[DatabaseViewController viewDidLoad] in DatabaseViewController.o
ld:未找到架构i386的符号
叮当声:错误:链接器命令失败,退出代码为1(使用-v查看调用)它是sqlite3\u exec。不是sqlite3_exe。 请查收。
exe中缺少“C”。以下是相同的示例代码。你可以在这里录制音频。你可以
#define DOCUMENTS_FOLDER [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]
- (void) startRecording{
UIBarButtonItem *stopButton = [[UIBarButtonItem alloc] initWithTitle:@"Stop" style:UIBarButtonItemStyleBordered target:self action:@selector(stopRecording)];
self.navigationItem.rightBarButtonItem = stopButton;
[stopButton release];
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
NSError *err = nil;
[audioSession setCategory :AVAudioSessionCategoryPlayAndRecord error:&err];
if(err){
NSLog(@"audioSession: %@ %d %@", [err domain], [err code], [[err userInfo] description]);
return;
}
[audioSession setActive:YES error:&err];
err = nil;
if(err){
NSLog(@"audioSession: %@ %d %@", [err domain], [err code], [[err userInfo] description]);
return;
}
recordSetting = [[NSMutableDictionary alloc] init];
[recordSetting setValue :[NSNumber numberWithInt:kAudioFormatLinearPCM] forKey:AVFormatIDKey];
[recordSetting setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey];
[recordSetting setValue:[NSNumber numberWithInt: 2] forKey:AVNumberOfChannelsKey];
[recordSetting setValue :[NSNumber numberWithInt:16] forKey:AVLinearPCMBitDepthKey];
[recordSetting setValue :[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsBigEndianKey];
[recordSetting setValue :[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsFloatKey];
// Create a new dated file
NSDate *now = [NSDate dateWithTimeIntervalSinceNow:0];
NSString *caldate = [now description];
recorderFilePath = [[NSString stringWithFormat:@"%@/%@.caf", DOCUMENTS_FOLDER, caldate] retain];
NSURL *url = [NSURL fileURLWithPath:recorderFilePath];
err = nil;
recorder = [[ AVAudioRecorder alloc] initWithURL:url settings:recordSetting error:&err];
if(!recorder){
NSLog(@"recorder: %@ %d %@", [err domain], [err code], [[err userInfo] description]);
UIAlertView *alert =
[[UIAlertView alloc] initWithTitle: @"Warning"
message: [err localizedDescription]
delegate: nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
return;
}
//prepare to record
[recorder setDelegate:self];
[recorder prepareToRecord];
recorder.meteringEnabled = YES;
BOOL audioHWAvailable = audioSession.inputIsAvailable;
if (! audioHWAvailable) {
UIAlertView *cantRecordAlert =
[[UIAlertView alloc] initWithTitle: @"Warning"
message: @"Audio input hardware not available"
delegate: nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[cantRecordAlert show];
[cantRecordAlert release];
return;
}
// start recording
[recorder recordForDuration:(NSTimeInterval) 10];
}
- (void) stopRecording{
[recorder stop];
NSURL *url = [NSURL fileURLWithPath: recorderFilePath];
NSError *err = nil;
NSData *audioData = [NSData dataWithContentsOfFile:[url path] options: 0 error:&err];
if(!audioData)
NSLog(@"audio data: %@ %d %@", [err domain], [err code], [[err userInfo] description]);
[editedObject setValue:[NSData dataWithContentsOfURL:url] forKey:editedFieldKey];
//[recorder deleteRecording];
NSFileManager *fm = [NSFileManager defaultManager];
err = nil;
[fm removeItemAtPath:[url path] error:&err];
if(err)
NSLog(@"File Manager: %@ %d %@", [err domain], [err code], [[err userInfo] description]);
UIBarButtonItem *startButton = [[UIBarButtonItem alloc] initWithTitle:@"Record" style:UIBarButtonItemStyleBordered target:self action:@selector(startRecording)];
self.navigationItem.rightBarButtonItem = startButton;
[startButton release];
}
- (void)audioRecorderDidFinishRecording:(AVAudioRecorder *) aRecorder successfully:(BOOL)flag
{
NSLog (@"audioRecorderDidFinishRecording:successfully:");
// your actions here
}
对于播放,您可以在停止录制方法中使用以下行:
NSURL* musicFile = [NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:@"click"
ofType:@"caf"]];
AVAudioPlayer *click = [[AVAudioPlayer alloc] initWithContentsOfURL:musicFile error:nil];
[click play];
[click release];
确保将录制的声音路径的正确URL传递到应用程序中。这些行将在音频播放器中为您播放。但它不会存储值运行此代码后,请检查application documents目录中创建的sqlite数据库。并检查是否创建了该表。:我不知道如何通过编程方式在i phone中拨打电话,因此请帮助我编写代码。要求我需要2个按钮如果我按第一个按钮通话应该是转到特定号码然后如果我按第二个按钮通话应该结束。。。有谁能告诉我密码吗…?首先,你不能在申请表中打电话。相反,您可以使用UIApplication类的openURL方法调用指定的号码。一旦你调用这个URl。您的应用程序将进入后台&iOS调用应用程序将打开。所以你们不能在你们的应用程序中结束通话,但可以使用按钮启动。是的,先生,我知道了。我还需要写一个录音应用程序。和两个按钮一样,如果我按第一个按钮,一个声音应该是录制的,第二个停止和播放按钮应该在那里,如果我单击播放按钮,它应该播放。帮帮我,我不知道,需要检查一下。你可以试着把钥匙放进去检查一下。希望它能起作用。遵循以下两个链接。“01:”02:::先生,在那个coe中有一些eror。错误是i++。。。RecordedTempFile=[NSURL fileURLWithPath:[NSTemporaryDirectory()stringByAppendingPathComponent:[NSString stringWithFormat:@“Myrecording%d.%@”、i++、@“caf”]];这是为您记录的文件名的路径。但它显示的错误,如“变量i在这里使用时未初始化”如何清除。。。