IPhone SDK - files in wrong spot (was can't open file)

Ok, so I figured out why I can't open my audio file, but it doesn't make any sense to me at all.
You see, if I place my file at the root of my file system, it reads it fine. This is odd, I would have guessed that the simulator would read files based on the bundle. This can't be right, how can I test? Here's my code:
CFStringRef fileString = (CFStringRef) [NSString stringWithFormat: @"test.caf"];
CFURLRef fileURL = CFURLCreateWithFileSystemPath (
kCFAllocatorDefault,
fileString,
kCFURLPOSIXPathStyle,
false
AudioFileID audioFileID;
OSStatus result = AudioFileOpenURL((CFURLRef) fileURL, kAudioFileReadPermission, 0, &audioFileID);
if (result != noErr) {
// lets try writing the file, see where it goes
char buf[8] = "1234567";
CFDataRef data = CFDataCreate (NULL, (const UInt8*)buf, 8);
long writeErr = noErr;
CFURLWriteDataAndPropertiesToResource(fileURL, data, nil, &writeErr);
NSLog(@"bad file open");
return ;
When I run this, the AudioFileOpen fails with a -43. When I catch this and then try to write to the file, I find that the file is created at my filesystems root, I get /test.caf with the contents "1234567" in it!
And, of course, if I delete that file and put my audio file there, then the AudioFileOpenURL works.
This is not useful.
Can anyone see what I'm doing wrong?
Thanks

Don't assume the current directory is anything sensible--construct an absolute path with -\[NSBundle pathForResource:ofType:\]. (After all, should the current directory be the sandbox's root, the application bundle, the Documents directory, or the tmp directory? I can come up with arguments for all four, but the app bundle's argument is probably the weakest.)

Similar Messages

  • Buy an iphone 4s on verizon ebay then I can not open because he had put find my iphone so I can not enter my apple id someone could help me

    buy an iphone 4s on verizon ebay then I can not open because he had put find my iphone so I can not enter my apple id someone could help me

    Welcome to the Apple Community.
    You can only contact the seller through eBay and ask them to remove their details from the phone via iCloud.com

  • Safari Browser in my iPhone 5S Hangs/Crashes when I was trying to open an Youtube video.Why is this happening?

    My iPhone 5S(Boasted as Worlds smartest smartphone) Hangs/Crashes when I was trying to open any Youtube video....
    Is there any fix for this apple.......???
    I love my iPhone 5s.But I'm pretty dissapointed.
    Coz...........
    Feeling ashamed of buying a smartphone worth Rs.51,000 which can't play a youtube video in its stock browser.
    Its a zippy task that can be done by a mobile worth Rs.5,100........
    Its shame on your part Apple..........
    Please fix this as soon as possible.
    Consider this bug & fix this in iOS 8......

    Google's Chrome browser is very well capable of doing what I want with ease....(on my iPhone)
    But Apple's Safari browser(much praised) cant move a speck on it...
    Why???........Whats wrong with the stock Safari Browser???

  • Iphone video sent to email...can't open...help

    I took a video with my iphone 3gs and I can't open it in my email.  What is the problem?  How can I fix this?
    Thanks for any help.

    Firefox doesn't do email, it's a web browser.
    If you are using Firefox to access your mail, you are using "web-mail". You need to seek support from your service provider or a forum for that service.
    If your problem is with Mozilla Thunderbird, see this forum for support.
    [http://www.mozillamessaging.com/en-US/support/] <br />
    or this one <br />
    [http://forums.mozillazine.org/viewforum.php?f=39]

  • Restored iPhone, signed in with wrong apple ID & can't use iTunes Match for 33 days!!u

    Hi,
    When I connected my iPhone 5 to itunes it said it couldn't read the device and I had to restore it.
    After I did this I signed in with my primary Apple ID, that I use for iCloud,  Mail, iMessage, Photo Stream etc. However most of my purchases & iTunes Match have been made on another Apple ID (that I used before iCloud was introduced)
    Now when I try and turn on iTunes match using this ID I get a message saying:
    "This device is already associated with an Apple ID. You can use iTunes Match on this device with just one apple ID every 90 days.  This device can be used with another Apple ID in 33 days"
    This is very very frustrating as I didn't realise what I had done when signing into the iPhone. I have sent a message to Apple to see if they can reset this before the 33 days so I can sign in with the correct ID for match.
    Anyone else had a similiar problem? I hope that there will be away in future of merging ID's so that this problem doesn't happen - I'm sure it's very common!
    Thanks
    Steven

    Yes, I did as you suggested and signed into the iTunes store with the Apple ID I use for purchases and iTunes Match.
    When I attempt to turn on iTunes match I am given the following message:
    "This device is already associated with an Apple ID. You can use iTunes Match on this device with just one apple ID every 90 days.  This device can be used with another Apple ID in 33 days"
    I believe this happened after I restored my iPhone5(as requested by iTunes) and logged back into the device with the incorrect ID, which was then set up to use for iTunes & App Store Purchases.
    When I then logged out of this ID and tried to use the correct ID, it was then that I received the message saying I cannot use it!
    If you think there is something else I can do to resolve this then please let me know.
    However, I have sent an email to Apple explaining what has happened.  If they have good procedures in place, they should be able to see my iTunes account(s) and the devices associated with it.  Remove the iPhone from the Apple ID that is is currently assocaited with and then I will be able to associate with the correct ID.
    It seems very straight forward!

  • What's wrong?  I can't open any PDF Files

    From emails or the web.  I get a message that reads Adobe reader could not open XXX because it is either not a supported file type or because the file has been damaged (for example it was sent as an email attachment and wasn't correctly decoded).  Any assistance is greatly appreciated.

    SeaSheller wrote:
    When I try to open them in the C drive, I get a white page with a small black x in a box in the top left corner.
    You're NOT opening them in Reader. That's a browser (specifically IE) or email (Outlook) symptom.

  • TS2383 What if doing all of this it still does not correct the problem?  Still tries to download again and stops at the same spot.  Can not open iPhotos at all now.

    I have been trying to download the new Iphoto update but on step 5 0f 9 it hangs up at 97% and will go no further.  Can not see my picutres in IPhoto of even close this without going to Force Quit.  will not let me download any of my new photos from my camera.  I have tried all the instructions in TS2383 but does not work

    Back Up and try rebuild the library: hold down the command and option (or alt) keys while launching iPhoto. Use the resulting dialogue to rebuild.
    If that fails:
    Restore from your back up, repair the Library and start again.

  • I'm using iphone 4S, and I can not open PDF file only from my husband email that using Mic outlook. It was very weird because I can received other email with pdf file from other people. can someone help.

    I'm using iphone 4S and ipad mini, and I can not open PDF file only from my husband email that using Mic outlook. It was very weird because I can received other email with pdf file from other people. Can someone help...
    Thanks in advance

    Hi Eidda,
    This may because the attachment is a winmail.dat file. I would recommend taking a look at the article below for more information. Note: the article is written for OS X mail, but does also apply to this situation.
    Mac OS X Mail: What is a winmail.dat attachment?
    http://support.apple.com/kb/HT2614
    -Griff W.

  • IPhone SDK b3: How I fixed broken (blank) Research Assistant

    Hello, I wanted to give this thread a new title as the original thread didn't indicate "iPhone SDK" in the title, and was in reference specifically to b2. The original thread:
    http://discussions.apple.com/message.jspa?messageID=6935634#6935634
    Here are my findings. Research Assistant was working great for me until I upgraded my original (b1) iPhone SDK directly to b3, skipping b2 entirely. In reading posts in the aforementioned thread, this problem seems to occur when going from b1 -> b2, and I can surmise probably also from b1 -> b2 -> b3.
    The comments in the aforementioned thread were useful in helping me reach a fixed state, for which I conclude a clean re-installation of b3 was necessary. Just doing steps 3) through 6), inclusive, _did not fix my problem._
    1) Uninstall iPhone b3 SDK
    sudo /developer/Libraray/uninstall-devtools --mode=all
    2) Reboot. Reinstall iPhone b3 SDK. Reboot.
    3) Launch Xcode. "Go to Xcode : Preferences... : Documentation"
    4) Click + to add the following entries (you might already see a bunch of grayed-out entires):
    /Developer/Platforms/iPhoneOS.platform/Developer/Documentation/DocSets
    /Developer/Documentation/DocSets
    /Library/Developer/Shared/Documentation/DocSets
    5) Exit and relaunch Xcode
    6) Go to "Project : Edit Project Settings" and click on "Rebuild Code Sense Index".
    After doing all of this, my Research Assistant now works. I wanted to share this with the community in hopes that others learning the iPhone SDK aren't dissuaded by this issue, which can cause a very substantial barrier to learning its APIs quickly.
    -Jeff Ishaq

    Thanks for all the tips. Unfortunately for me it still doesn't work
    After trying for a day I give up ... bulky docs pane here I come.
    Might be because I am using standard Xcode Dev Tools and not the iPhone SDK version of it, but I am still hoping Apple will release a fix for this annoying bug.

  • My iWeb site is receiving an error - can't open file.

    I've got quite a big iWeb website (5.51GB) and this is the first time I encountered this problem. Today, I tried starting my website and it would not open. The error was "can't open file '.../domain ed.sites2.' I can't seem to fix it with the things I'm finding on this community support centre.

    The following might be helpful: in Lion the Library folder is now invisible. To make it permanently visible enter the following in the Terminal application window: chflags nohidden ~/Library and hit the Enter button - 10.7: Un-hide the User Library folder.
    To open your domain file in Lion or to switch between multiple domain files Cyclosaurus has provided us with the following script that you can make into an Applescript application with Script Editor. Open Script Editor, copy and paste the script below into Script Editor's window and save as an application.
    do shell script "/usr/bin/defaults write com.apple.iWeb iWebDefaultsDocumentPath -boolean no"delay 1
    tell application "iWeb" to activate
    Just launch the application, find and select the domain file you want to open and it will open with iWeb. It modifies the iWeb preference file each time it's launched so one can switch between domain files.
    You can download an already compiled version with this link: iWeb Switch Domain.
    WARNING: iWeb Switch Domain will overwrite an existing Domain.sites2 file if you select to create a new domain in the same folder.  So rename your domain files once they've been created to something other than the default name.
    OT

  • Can't open EPS with CS6 - sent from someone using CS4

    Friend mailed me an .eps file from CS4 and I can't open it on CS6. What's wrong??
    "Can't open the illustration. Could not complete the requested operation."

    Can your friend open the copy from their sent folder in their email application? I ask because it is possible the file was corrupted in the send. If they can open it, how are you opening it? Did you copy the file from the email to your computer instead of trying to open it out of your email app?
    Take care, Mike

  • Lumia 710 can't open E-mails...

    I am trying to send the Pages & Numbers files saved on my iPhone to my Lumia 710, i have the option to send it by Pages & Numbers or Word & Excel, whenever i try to send either by e-mail to my Windows Phone, it downloads the file but it says
    "Can't Open Attachment"
    Oops! We're not sure what's wrong, but we can't open this file."
    i have tried sending it with different e-mail addresses (GMX, Yahoo Rocketmail, G-Mail, Hotmail) but still it comes up with the same message. Numbers file size is 581KB, Excel file size is 84KB.
    I have the option to send it by PDF, i have tried it but i can the same message appears. 
    Thanks in advance.
    sm_19

    Hey sm_19, Welcome to the Nokia Forums.
    Please check that your e-mail inboxes are not full or nearly full and also that you have sufficient phone memory left on your phone to save/open the file.
    Also please check that you have installed the latest software update onto your phone.
    I hope this has helped!
    Sheldrick 
    Press the 'Accept As Solution' icon if I have solved your problem, Kudos my post if my advice has helped you!

  • My phone 3gs is block how can i open it

    Hi,
    i have 3GS iphone, i did an upgread to my iphone then it's bloucked and i can't open it even from the iphone or my Mac labtop. so what can i do i'm really giveup from it and start hate iphone????
    Thanks,
    Mohammed

    mohammedfromsaint john wrote:
    Hi,
    i have 3GS iphone, i did an upgread to my iphone then it's bloucked and i can't open it even from the iphone or my Mac labtop. so what can i do i'm really giveup from it and start hate iphone????
    Thanks,
    Mohammed
    If you are outside of the US, than you may have a phone that is locked to AT&T and was hacked to make it work on your carrier. If you upgrade a hacked phone, it relocks to the original carrier. If this is the case, nothing you can do, AT&T will not unlock your phone. Search the thousands of threads about unlocking. Jailbreaking and hacking are not topics that can be discussed on this forum.

  • I bought an iPhone from Ebay and it did not turn on so I looked on WinSCP and it said there was NO files PLEASE can someone send me iPhon 4 files!

    I bought an iPhone from Ebay and it did not turn on so I looked on WinSCP and it said there was NO files PLEASE can someone send me iPhone 4 files!

    No, no one can do that. You need to try restoring it:
    Placing your device into recovery (DFU-Device Firmware Upgrade) mode:
    Follow these steps to place your iOS device into recovery mode. If your iOS device is already in recovery mode, you can proceed immediately to step 6.
       1. Disconnect the USB cable from the iPhone, iPad, or iPod touch, but leave the
           other end of the cable connected to your computer's USB port.
       2. Turn off the device: Press and hold the Sleep/Wake button for a few seconds
           until the red slider appears, then slide the slider. Wait for the device to turn off.
                  * If you cannot turn off the device using the slider, press and hold the
                    Sleep/Wake and Home buttons at the same time. When the device turns off,
                    release the Sleep/Wake and Home buttons.
      3. While pressing and holding the Home button, reconnect the USB cable to the
           device. The device should turn on. Note: If you see the battery charge warning,
           let the device charge for at least ten minutes to ensure that the battery has some
           charge, and then start with step 2 again.
      4. Continue holding the Home button until you see the "Connect to iTunes" screen.
           When this screen appears you can release the Home button:
      5. If necessary, open iTunes. You should see the following "recovery mode" alert:
      6. Use iTunes to restore the device.
    If you don't see the "Connect to iTunes" screen, try these steps again. If you see the "Connect to iTunes" screen but the device does not appear in iTunes, see this article and its related links.
    Note: When using recovery mode, you can only restore the device. All user content on the device will be erased, but if you had previously synced with iTunes on this computer, you can restore from a previous backup. See this article for more information.

  • HT1212 My little children Majd enter the wrong passcode for more than 10 times, my iPhone automatically got reset all data was deleted. I managed to retrieve the contacts only but I'm unable to retrieve my SMS's and my photos???? Can you help me please ??

    My little children Majd entered the wrong passcode for more than 10 times, my iPhone automatically got reset all data was deleted. I managed to retrieve the contacts only but I'm unable to retrieve my SMS's and my photos???? Can you help me please ???

    Hi,
    Did you ever back up your phone on the computer?
    Did you use photo stream at all?
    May I suggest changing your passcode lock to a letters and numbers lock (if not all ready it will make your iphone more secure and a restore lock otion shouldent be needed). Then change your setting as well preventing restore after ten incorect passwords.
    kc

Maybe you are looking for