views:

66

answers:

2

Hi, I'm a young iphone dev who needs to download a .txt file from a web (I got a ftp sever) to update a small database on the device. Anyone could give me an advice of how to do this?

Thanks.

+2  A: 

Downloading it (see Downloading to a Predetermined Destination)

NSURLRequest* req = [NSURLRequest requestWithURL:[NSURL URLWithString:@"ftp://myftpserver/path/to/file.txt"]];

Reading it (see String Programming Guide)

float aFloat;
NSScanner *theScanner = [NSScanner scannerWithString:aString];
while ([theScanner isAtEnd] == NO) {

    [theScanner scanFloat:&aFloat];
    // implementation continues...
}

Updating the Database, it all depends on what you are using for a Database. I would start with the Core Data Overview and SQLite docs

slf
A: 

I think using a NSURLDownload would be better as it is meant for it lol.

all you need: http://developer.apple.com/mac/library/documentation/cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLDownload.html#//apple_ref/doc/uid/20001839-BAJEAIEE

Antwan van Houdt