0

I am having a bit of trouble with my software. I am wanting to upload a simple xml file to a server through FTP. I am not really sure how to do this in Objective-C. I saw something like this, but it really did not help me upload a file:

url = [NSURL URLWithString:@"ftp://username:[email protected]"];

I am more familiar with C#, but how would i go about uploading a file through FTP?

Thanks,

Elite Gamer

1 Answer 1

1

Example

You do the request and set the stream delegate:

NSURL* url = [NSURL URLWithString:@"ftp://username:[email protected]"];
CFReadStreamRef stream = CFReadStreamCreateWithFTPURL(NULL, (__bridge CFURLRef) url);
stream.delegate= self;
[stream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[stream open];

Then you handle it with this method:

- (void)stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode;

PS: Release the stream with CFRelease() when you don't need it anymore.

Reference

CFNetworking framework (look at the CFFTP API): https://developer.apple.com/library/mac/#documentation/Networking/Conceptual/CFNetwork/Concepts/Concepts.html

Sample: http://developer.apple.com/library/ios/#samplecode/SimpleFTPSample/Introduction/Intro.html

2
  • How would i do the upload? Mar 28, 2013 at 13:35
  • thanks, but could you write some code just to get me started...i just need somewhere to start. Thanks Mar 28, 2013 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.