0
我试图用下面的代码通过FTP发送一个字符串,但我得到一个错误:发送字符串:收到错误
{
//miscellaneous lines of code.....
//Convert contents of shopping cart into a property list
[Cart serializeCart];
//now need to transport the propertyList to the webserver
//first step is get the serialized propertylist from the documents folder
NSString *pathToSerializedCart = [rootPath stringByAppendingPathComponent:@"serializedCart.plist"];
NSString *shoppingCartString;
if (![fileManager fileExistsAtPath:pathToSerializedCart])
{
NSLog(@"ERROR:\nCouldnt find serialized cart in documents folder.");
}
else
{
NSData *serializedData = [NSData dataWithContentsOfFile:pathToSerializedCart];
shoppingCartString = [[NSString alloc] initWithData:serializedData encoding:NSUTF8StringEncoding];
}
NSLog(@"%@", shoppingCartString);
//Now that the cart is converted into a string. it is ready for transport
NSURL *url = [NSURL URLWithString:@"ftp://username:[email protected]/folder/serializedCart.xml"];
BOOL OK =[shoppingCartString writeToURL:url atomically:NO encoding:NSUTF8StringEncoding error:&error];
if(!OK) {
NSLog(@"Error writing to file %@ , error = %@", url, [error localizedFailureReason]);
}
我得到以下控制台输出的代码:
Error writing to file ftp://username:[email protected]/folder/serializedCart.xml , error = (null)
其中一个变量:_domain
在最后一行此错误对象时,我鼠标移到它在调试过程中说NSCocoaErrorDomain
我不知道怎么调试ŧ他的。 有人可以提出任何建议吗?