【发布时间】:2011-06-20 02:31:01
【问题描述】:
我正在尝试使用以下代码通过 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:password@domainName.com/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:password@domainName.com/folder/serializedCart.xml , error = (null)
变量之一:_domain在这个错误对象的最后一行的时候,我在调试的时候鼠标悬停在上面说NSCocoaErrorDomain
我不确定如何调试它。 有人可以给点建议吗?
【问题讨论】: