2013-06-29 61 views
0

首先對不起我的英語我該如何解決這個錯誤?

我已經與我的代碼有問題,我嘗試做一個完善的計劃,但在我的代碼出現此錯誤:

Invalid operands to binary expression ('CFURLRef' (aka 'const struct __CFURL *') and 'CFURLRef') 

,這是我的全部代碼:

- (IBAction)tocar:(id)sender { 
CFBundleRef mainBundle = CFBundleGetMainBundle(); 
CFURLRef soundfileURLRef; 
soundfileURLRef *CFBundleCopyResourceURL (mainBundle, (CFStringRef) @"Botao", CFSTR ("mp3"), NULL); 
UInt32 SoundID; 
AudioServicesCreateSystemSoundID(soundfileURLRef, &SoundID); 
AudioServicesPlaySystemSound(SoundID); 
} 

回答

0

CFBundleCopyResourceURL線被搞砸了,等號變成一個星號;

soundfileURLRef *CFBundleCopyResourceURL (mainBundle, 
          (CFStringRef) @"Botao", CFSTR ("mp3"), NULL); 

...應該是...

soundFileURLRef = CFBundleCopyResourceURL(mainBundle, 
          (CFStringRef) @"Botao", CFSTR ("mp3"), NULL); 
2

假設你寫的代碼是你實際使用的一個,這條線是奇數:

soundfileURLRef *CFBundleCopyResourceURL (mainBundle, (CFStringRef) @"Botao", 
    CFSTR ("mp3"), NULL); 

的asteriks(*)應equlas(=

我覺得應該是

soundfileURLRef = CFBundleCopyResourceURL (mainBundle, (CFStringRef) @"Botao", 
    CFSTR ("mp3"), NULL); 
+0

謝謝,它的工作。 – Bueno

相關問題