Hi,
I have a delphi server, and an IOS client.
There is a method where IOS client could ask a file to the server.
The delphi (server) part is like this :
function TWSYCatService.getFile(const fileName: AnsiString; const folder: AnsiString; out fileData: Binary; out fileSize: Int64): Boolean;
Var
fileStream: TFileStream;
res : boolean;
currentFolder : AnsiString;
Begin
res:= false;
Try
currentFolder := ExtractFilePath(ParamStr(0));
fileStream := TFileStream.Create(currentFolder + folder + ‘/’ + fileName, fmopenRead);
fileSize := fileStream.Size;
fileData := nil;
if fileSize > 0 then
begin
fileData := Binary.Create;
fileData.SetSize(fileSize);
fileData.CopyFrom(fileStream,0);
fileData.Position := 0;
End;
Finally
if (fileStream <> nil) then FreeAndNil(fileStream);
End;
result := res;
End;
The XCode part is like this :
-(BOOL) getFileFromServer:(id)args
{
NSString *fileName = [TiUtils stringValue:[args objectAtIndex:0]];
NSString *folder = [TiUtils stringValue:[args objectAtIndex:1]];
NSString *destFileName = [TiUtils stringValue:[args objectAtIndex:2]];
NSData stream;
int64 fileSize;
NSLog(@“Ask file to server”);
BOOL res = [MyService getFile:fileName :folder :&stream :fileSize];
NSLog(@“Size : @d”,fileSize);
NSLog(@“Length : @d”,[stream length]);
if (res) {
NSLog(@“Writing to file”);
res = [stream writeToFile:destFileName atomically:YES];
}
return res;
}
the app crash when calling getFile. No problem on server side.
other web service methods are called without any problem.
Any idea ?
Regards