osx - Objective c: How to know the progress of formatting USB drive in using NSTask -
i use nstask execute format usb drive ntfs fat32. works well, know progress when starts format.
here code:
nstask *task = [nstask new]; [task setlaunchpath:@"/usr/bin/env"]; [task setarguments:[nsarray arraywithobjects:@"diskutil", @"erasevolume", @"ms-dos" ,name ,path,nil]]; nspipe *pipe = [nspipe pipe]; [task setstandardoutput:pipe]; [task launch]; [task waituntilexit];
how add progress keep track of formatting.(like percentage done...) !!
the task wrap nstask needs first providing progress updates. there, can watch stderr , stdout. if there updates them, can interpret , post notification main thread. use notification make gui updates.
Comments
Post a Comment