Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 02-04-2010, 04:45 AM   #1 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 22
iphonemobdev is on a distinguished road
Default NSFileHandle, weird problem in iphone

Hi ,
i am downloading an mp3 file using NSURLConnection and saving it to a file . The problem is mp3 file is created (found the mp3 file created when using simulator), but i cannot access the mp3 file . Any ideas?!!!!!


This is the code i'm using

filename = [[NSSearchPathForDirectoriesInDomains(NSDocumentDire ctory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:save_name];
[[NSFileManager defaultManager] createFileAtPath:filename contents:nil attributes:nil];

file = [[NSFileHandle fileHandleForUpdatingAtPath:filename] retain];// file is in .h

}

if (file) {

[file seekToEndOfFile];


} [file writeData:data];
iphonemobdev is offline   Reply With Quote
Old 02-04-2010, 10:19 AM   #2 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

It depends on where this code is being used. It seems as though you're always adding to the end of the.mp3. So as you try downloading multiple times, you just get one big corrupted mp3 file.
smithdale87 is offline   Reply With Quote
Reply

Bookmarks

Tags
file, iphone, nsfilehandle, nsurlconnection

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 320
6 members and 314 guests
2Apps1Day, akacaj, SLIC, soohyun, Techgirl-52, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,650
Threads: 94,115
Posts: 402,887
Top Poster: BrianSlick (7,990)
Welcome to our newest member, soohyun
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 10:06 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0