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
我不知道怎麼調試ŧ他的。 有人可以提出任何建議嗎?