IPhone SDK - Sample code to download a file in a thread

I am looking for a starting point to implement a download manager. My requirements are simple.
I want to show a UIProgressView in a view controller and update it as i download file(s) from the internet. The view will have a cancel button, so the view cannot block on downloading the files. The cancel should cancel the download thread in such a way that the thread can cleanup if required.
To achieve this i guess i will have to download the file(s) in a separate thread and then figure out a way to update the progress bar in the UI thread based on the bytes downloaded from the web.
Can someone point me to code sample which demonstrates this interaction OR help me with their suggestions?
Thanks in advnace,
Shiva

NSURLRequest is asynchronous by default, so really all you need to do is prepare your NSURLRequests, fire them all off, and then in the delegate you can update the progress bar as each of them returns.
I'd suggest just having the progress bar update based on how many requests have completed out of the full set, rather than based on the number of bytes downloaded. NSURLResponse doesn't give you byte-by-byte callbacks, so it's quite hard to work out how far along an individual request has progressed.
Read the URL Loading Scheme document in the API - it's full of example code that you can use.

Similar Messages

  • Missing "Crash Landing" iPhone SDK sample code.

    Ok, I'm at the phase in my project where I need to start integrating the audio. I've been told , and theres plenty of references on the net, to try and base off a piece of code off the "Crash Landing" sample code.
    Google tells me it used to be on the Iphone dev page on apples site, but there is no reference to the sample code on Apples site and apples search engine comes up blank.
    Has this been removed? If it has, is there anywhere else that features examples of using the OpenAL architecture. I realise there is a new architecture for audio introduced, but for various reasons, we can't use it.

    Hi i need reference from the crash landing code for my own development...it was there on my machin some months back and i hve also installed on my iphone also using xcode...but i recently discovered the sample code is not there on my machine as mistakenly i have removed it from my machine. i need it so if someone can provide me the sample code i can easily over come the issue in my development as it is been resolve in the crash landing. please if i can get the code it will be of great help.

  • Bug in SeismicXML iPhone SDK sample code

    I'm writing an app based on SeismicXML for the XML parsing code, and it turns out there's a bug in the SeismicXML parser. The last item always seems to end up not getting saved to the list. This bug becomes evident when you change:
    self.earthquakeLocationLabel.text = newQuake.location;
    to
    self.earthquakeLocationLabel.text = newQuake.description;
    in TableViewCell.m.
    I've banged my head into this in my own app only to test out the upstream sample code and find out that it has the same error. There's something about the last item that it parses that causes a problem.
    I'm very new to Objective C but this feels like some sort of object initialization/retention/reuse problem...any pointers?

    I found two reasons why this is not working. Both found in didStartElement(...)
    #1
    if (parsedEarthquakesCounter >= MAX_EARTHQUAKES) {
    parser abortParsing;
    This is premature. If MAX_EARTHQUAKES is set to 5, this condition will be true for any start element within that fifth entry.
    #2
    The call to addToEarthquakeList()
    This is again premature. Since addToEarthquakeList also reloads the displayed table view, the fifth and last entry will never be displayed. The table is reloaded before any data is placed within the Earthquake object for that entry.
    Solution
    Remove both the if test case and function call above from didStartElement(...)
    In didEndElement(...) add the case
    else if (elementName isEqualToString:@"entry") {
    //insert call to addToEarthquakeList here
    //test for MAX_EARTHQUAKES HERE
    }

  • Not able to use Visual studio 2010 editor intelligence while running SDK sample code ?

    whenevr i start sdk sample project in visual studio i can build it ,debug it ,run it but the problem is that VS 2010 editor showing lots of red lines under many lines of code which on Mouse hover show some kind of error(mostly _____ is undefined) moreover i am not able to use intelligence feature of VS editor and i have to check reference of SDK everey time .what is the solution to this problem .

    1. Create environment variable INDESIGN_SDK_DIR with path to root folder of your SDK
    e.x  INDESIGN_SDK_DIR = "C:\SDK\InDesignCS6SDK"
    2. In your project add this to project settings:
    "VSProject"->"Proporties"->"Configuration Proporties"->"VC++ Directories"->"Executable Directories" add:
    $(INDESIGN_SDK_DIR)\devtools\bin
    "VSProject"->"Proporties"->"Configuration Proporties"->"C++"->"General"->"Additional Include Directories" add:
    $(INDESIGN_SDK_DIR)\source\precomp\msvc;
    $(INDESIGN_SDK_DIR)\source\public\interfaces\xmedia;
    $(INDESIGN_SDK_DIR)\source\public\interfaces\preflight;
    $(INDESIGN_SDK_DIR)\source\public\interfaces\ui;
    $(INDESIGN_SDK_DIR)\source\public\interfaces\tables;
    $(INDESIGN_SDK_DIR)\source\public\interfaces\text;
    $(INDESIGN_SDK_DIR)\source\public\interfaces\graphics;
    $(INDESIGN_SDK_DIR)\source\public\libs\widgetbin\includes;
    $(INDESIGN_SDK_DIR)\source\public\interfaces\workgroup;
    $(INDESIGN_SDK_DIR)\source\public\interfaces\interactive;
    $(INDESIGN_SDK_DIR)\source\public\interfaces\interactive\ui;
    $(INDESIGN_SDK_DIR)\source\public\interfaces\colormgmt;
    $(INDESIGN_SDK_DIR)\source\public\interfaces\utils;
    $(INDESIGN_SDK_DIR)\source\public\interfaces\incopy;
    $(INDESIGN_SDK_DIR)\source\public\interfaces\layout;
    $(INDESIGN_SDK_DIR)\source\public\interfaces\architecture;
    $(INDESIGN_SDK_DIR)\source\public\interfaces\cjk;
    $(INDESIGN_SDK_DIR)\source\precomp\common;
    $(INDESIGN_SDK_DIR)\source\public\includes;
    $(INDESIGN_SDK_DIR)\source\public\libs\publiclib\plugins;
    $(INDESIGN_SDK_DIR)\source\public\libs\publiclib\files;
    $(INDESIGN_SDK_DIR)\source\public\libs\publiclib\objectmodel;
    $(INDESIGN_SDK_DIR)\external\asl\boost_libraries;
    $(INDESIGN_SDK_DIR)\source\sdksamples\common;
    $(INDESIGN_SDK_DIR)\external\afl\includes
    "VSProject"->"Proporties"->"Configuration Proporties"->"Linker"->"General"->"Additional Library Directories" add:
    $(INDESIGN_SDK_DIR)\build\win\objr;
    $(INDESIGN_SDK_DIR)\external\afl\libs\win\release;
    $(INDESIGN_SDK_DIR)\external\icu\libs\win\release
    "VSProject"->"Proporties"->"Configuration Proporties"->"Linker"->"Input"->"Additional Dependencies" add:
    PMRuntime.lib;
    Public.lib;
    WidgetBin.lib;
    AFL.lib;

  • IPhone Kalimba sample code

    Hi all,
    I can't find it from the current Apple iPhone developer page, but there was a
    sample code called Kalimba for iPhone SDK (in Beta 4 release, I think). I played
    with this sample recently, and the sound does not work anymore when I run the
    code in the simulator. I remember it used to work. Was this code deprecated?
    syy

    Kalimba worked in the earlier versions of the SDK. The routine used to create the sound was eliminated during one of the revisions of the SDK. Kalimba was supposed to be rebuilt using the Interface Builder but never was. Apple never re-released it to work with the later SDKs

  • Report Engine SDK sample code questions

    Hello,
    I've been able to view a boxi report in an iframe via the Enterprise SDK by modifying the sample code in the HowToViewWebiReports_VB example.
    I'm not totally happy with the way that's working, so I'm looking at using the Report Engine SDK, although I understand it's performance and scalability isn't quite as good as the Enterprise SDK.
    I'm a VB.NET guy, not a C# guy, and I'm not clear on how the wssdk_net2.0_portal_sample_12.0_en example is supposed to work.
    I don't have one and my CMS server is running Tomcat, not IIS so there's not going to be an ASP.NET web service running there.
    In the dsws.config for the wssdk_net2.0_portal_sample_12.0_en example I put the name of the CMS server, but it's looking for a web service at http://cmsservername:8080/dswsbobje/services/Session, but I get a 404 when i try to hit that. 
    I'm not familiar with Tomcat, but in searching around on the server, I see a dswsbobje directory under the webapps in my Tomcat installation, but I don't see a services or a Session folder underneath that.  In the dswsbobje folder I see the following folders:
    BOAR-INF
    META-INF
    WEB-INF
    xsd
    Is there something else that needs to be installed on the Tomcat server to get the web service running?
    -Eric

    It looks like I have something there.  When I launch launch http://servername:8080/dswsbobje,  I see:
    Apache-AXIS
    Hello! Welcome to Apache-Axis.
    What do you want to do today?
    Validate the local installation's configuration
    see below if this does not work.
    To enable the disabled features, uncomment the appropriate declarations in WEB-INF/web.xml in the webapplication and restart it.
    Validating Axis
    If the "happyaxis" validation page displays an exception instead of a status page, the likely cause is that you have multiple XML parsers in your classpath. Clean up your classpath by eliminating extraneous parsers.
    I clicked on the "Validate" link and I see:
    Axis Happiness Page
    Examining webapp configuration
    QaaWS Configuration
    QaaWS Servlet is not valid.
    ErrorServer servername not found or server may be down
    See Web Application log to get more info or read QaaWS v2 documentation starting with section
    Perhaps this environment needs some additional configuration?

  • Iphone sdk 3.2 wont download after 2.35 gb

    hi i am downloading iphone sdk 3.2 it says 3hours and 20 minutes required to complete 2.31 gb but downloads get beyond 2.31 gb to 2.35 gb and after that it hangs and when i stopped it and resume it again then it says no server connection for that,then i just remove .download n make it .dmg n double clicked on that then it says image not recognised, then i again put .download in front of .dmg then it start downloading through the beginning wat should i do now?
    Message was edited by: funmania

    Do you have at least 5 GB of free space on your hard disk? Preferably more.

  • Problem in iPhone SDK Sample: [CrashLanding ]

    iPhone SDK build : build 9M2199a
    Sample: CrashLanding
    Version: 1.7
    OpenGL swap buffer method seems to fails sometimes resulting in a crappy blink display. The display seems split into two images. The screen goes messy, I can view the backbuffer blinking over frontbuffer with no drawing update on it.
    Thanks,
    Julien Meyer
    Jadegame.com

    I developed my application based on the CrashLanding sample. I have inherited the same rendering failure. The swap occurs, but it's presenting stale data for one of the frames. The stale data appears to be the first frame rendered. The failure occurs either immediately, or not at all. Restarting the application usually makes the problem go away.
    Has anyone determined a fix for this?
    Thank you,
    Joel-

  • Code for downloading a file

    Can some one provide me wit da code for downloadind a file.

    import com.jscape.inet.ftp.*;
    Establishing a connection
    In order to communicate with an FTP server you must first establish a network connection to the FTP server.
    // create Ftp instance with FTP hostname, username and password as arguments
    Ftp ftp = new Ftp("ftp.myserver.com","jsmith","secret");
    // establish connection
    ftp.connect();
    Perform a directory listing
    Once connected you may wish to perform a directory listing on the FTP server. The directory listing will return a relative listing of files and directories that are on the FTP server.
    // perform directory listing
    String listing = ftp.getDirListingAsString();
    // print directory listing to console
    System.out.println(listing);
    Alternatively you may use the getDirListing method. This method parses the results and returns a java.util.Enumeration of FtpFile. Using this method you may then iterate through the Enumeration and evaluate the contents of each file or directory programmatically. Note: This method is only for use by FTP servers which display directory listing using the UNIX or MS-DOS mode. For more information see the Ftp.getDirListing method in the JavaDoc.
    // Perform directory listing
    Enumeration files = ftp.getDirListing();
    // iterate through listing
    while(files.hasMoreElements()) {
    FtpFile file = (FtpFile)files.nextElement();
    // only print files that are directories;
    if(file.isDirectory()) {
    System.out.println(file.getName());
    Changing your local directory
    Your local directory is the directory that you wish to use when transferring files to / from the FTP server. By default this is the directory that the Java executable was invoked from. To change this setting simply invoke the setLocalDir method.
    // change local directory
    ftp.setLocalDir(new File("C:/tmp");
    Changing your remote directory
    Your remote directory represents your current directory on the FTP server. By default this is the directory that is assigned when first logging into the FTP server. To change this setting simply invoke the setDir method.
    // Change remote directory
    ftp.setDir("temp");
    Setting the transfer mode
    Files transferred to / from an FTP server may be transmitted using binary or ASCII modes. The binary transfer mode transfers files without performing any conversion. Binary transfer is generally used for files that are binary in nature such as images, executables etc. The ASCII transfer mode transfers files converting new line characters to the system dependent new line character used by the operating system performing the transfer request. ASCII transfer mode is generally used when downloading text only files. The default transfer mode is binary.
    // change transfer mode to ASCII
    ftp.setAscii();
    // change transfer mode to binary
    ftp.setBinary();
    Downloading files
    To download a file simple invoke the download method. File will be transferred using the current transfer mode and saved in your local directory. See Setting the transfer mode and Changing your local directory for more information. There are other methods that you may use for downloading files. These include methods for downloading entire directories and downloading files matching a regular expression. For more information see the JavaDoc.
    // download a file named test.txt in remote directory
    ftp.download("test.txt");
    Uploading files
    To upload a file simply invoke the upload method. File will be transferred using the current transfer mode and saved in your remote directory. See Setting the transfer mode and Changing your remote directory for more information. There are other methods that you may use for uploading files. These include methods for uploading entire directories and uploading files matching a regular expression. For more information see the JavaDoc.
    // upload a file named test.txt in c:/tmp directory
    ftp.upload(new File("c:/tmp/test.txt"));
    Releasing the connection
    Once you have finished sending your email message(s) it is important that you disconnect from the FTP server. This is easily accomplished using the code below.
    // release the FTP server connection
    ftp.disconnect();
    With Regards,
    Dipak Sodani.

  • SDK sample code for Changing name of Exported file thru Webi schedule

    Hi experts,
    I am wanting to know if someone has got any sample Java SDK code which I can use to login to FTP and rename the pdf files generated from webi schedule script and append customised date format towards the end.

    Hi Prabhat,
    For online samples
    https://www.sdn.sap.com/irj/boc/samples
    For detalied descripation on BO SDK.
    https://www.sdn.sap.com/irj/boc/sdklibrary
    For BOE SDK guide.
    http://help.sap.com/businessobject/product_guides/boexir31/en/boesdk_java_dg_12_en.zip
    This would give you complete information on scheduling.
    For RE SDK guide.
    http://help.sap.com/businessobject/product_guides/boexir31/en/resdk_java_dg_12_en.zip
    This would give you information on how deal with Desktop intelligence report and Web intelligence report.

  • Procedure/sample code to download alv output in HTM format & mail to user.

    Hello Experts,
    I've a requirement to run the Alv report at background. But i need to download the alv output in HTM fomat because it has subtotal values & look wise downloaded HTM format will be same as that of ALV output. Then send the attachment through mail to users. I'm not intersted in  downloading  internal table dierctly to HTM format.
    Will the code for alv display & downloading in HTM format & forwarding via email  is all done in one single  program or in 2 differnt programs . pls guide me on this.
    I'm using FM REUSE_ALV_GRID_DISPLAY to display output with subtotals.
    Pls anyone there suggest me the steps to download ALV output in HTM format & the forward the same  to user ID through Lotus notes.
    Regards
    Devika.S

    Hi,
    This can be achieved without coding .
    Fore ground Scenario:
    1. Downloading as HTM . In foreground you can do this by using Export---> Local file
    option in ALV grid.
    Background Scenario:
    2. In background while sending mail , You have to achieve the same through customisation settings as wexplained below.
    In SM36 -- > Spool List Recipient, give the reciepient id and click on copy. Now when the Background job will be finished,
    the reciepient mentioned above will recieve the mail , but in ALI format.
    To convert the same to HTM format, you need to do customisation changes in SCOT
    goto SCOT>Expant the node INT>Double click on Email-->Beside Internet we have SET tab , click on that -->
    select the radio button " all formats except the following ">In the near by box type ALI>then click on the tick Mark.
    Then go to SCOT>Settings>Conversion Rules-->there
    create a new row with, Format->ALI , To Format->HTM , Ranking 1, FM -> SX_OBJECT_CONVERT_ALI_HTM.
    Now when the mail will be sent, it will not go in ALI, but in HTM format.
    Hope this helps you out.

  • Sample code to download and open an Asset

    For anyone who wants to download an asset from the web and load it into your Adobe application, this is how I did it:
    // .js
    var TMP_FOLDER="/tmp/com.mb.extension/";
    var doOpen = function(uri) {
              var xhr = new XMLHttpRequest();
              xhr.open("GET", uri, true);
              xhr.responseType = "blob";
              xhr.onload = function(event) {
                        var blob = this.response;
                        var data;
                        blobToBase64(blob, function(result) {
                                  data = result;
                                  var file = TMP_FOLDER+name;
                                  window.cep.fs.writeFile(file, data, cep.encoding.Base64);
                                  doOpenFile(file);
              xhr.send();
    function doOpenFile(file) {
              var ppid = "ILST";
              var extScript = "$._ext_"+ppid+".open('"+file+"')";
              evalScript(extScript);
    var base64ToBlob = function(base64, callback) {
      var binary = atob(base64);
      var len = binary.length;
      var buffer = new ArrayBuffer(len);
      var view = new Uint8Array(buffer);
      for (var i = 0; i < len; i++) {
           view[i] = binary.charCodeAt(i);
      callback(new Blob([view]));
    // .jsx
    $._ext_ILST={
        open : function(path) {
            openDocument(path);
    var openDocument = function(path) {
        return app.open(File(path));

    I don't know why, but when I use this code. The file was downloaded right, but Illustrator doesn't open the file.
    When doOpenFile is fired the args are correct, because I have debug it in console. But I think the problem is with the JSX file, sure I'm doing something wrong.
    Anybody could guide me about it?
    I'm newbie trying to script Adobe Extensions.

  • Missing Oracle Sample Schemas - How Download complete Files

    Dear DBA's
    I appreciate if someone could tell me how setup the ORACLE SAMPLE SCHEMAS, because all my demo folders in 10g and 11G
    $ORACLE_HOME/demo/schema/hr or oe or any other chema there are fiesl missing,
    for instnace looking at the Procedure in doc
    http://download.oracle.com/docs/cd/B28359_01/server.111/b28328.pdf
    it says to run "hr_main.sql" script in folder $ORACLE_HOME/demo/schema/human_resources
    But I can't find any file"hr_main"
    then for PM Schema it's supposed to have a file pm_main.sql !!!! I can't find .....
    The same for SH (Sales History) they say to run the "sh_main.sql" but i can't find anything like "Main"
    Can you please help me to compltely setup the sample schemas ?
    Txs

    I am having the same problem.
    I am running XE and the only sample schema that exists there is HR.
    OE and SH...are not there
    I downloaded companion CD 10 minutes ago from
    http://www.oracle.com/technetwork/database/10201winsoft-095341.html
    and searched through the whole companion and no
    files like :
    sh_main.sql
    mksample
    nothing!
    User Steve Callan placed a data pump file on
    http://www.dbasupport.com/oracle/ora11g/Installing-Oracle-Database-Sample-Schemas-using-Data-Pump.shtml
    but he created it without version parameter, so people who are running data pum from older versions cannot import it.
    I made a comment on the article he posted .
    user13106173 pointed out a link where you can get OE and HR, but I need SH sample schema as well
    So please can somebody direct me to anyplace I can get ALL THE Sample schemas

  • SDK Sample Code

    Hi,
    I have tested a form from B1DE as given in elearning.
    I have used VB.net and repeated all steps with this tool
    and I can Find,Add, update data in my form without any problem
    Now my question are
    1) In VB.Net there are no components i.e. UI Interface
    2) How can I add ChooseFromList to a specific field
    Please Help
    Best Regards,
    Umer Nasim Mirza

    Hi Umer,
    This is the way to add a CFL :
    1. Define your CFLs :
    Here i create a CFL with conditions :
    private void AddChooseFromList(SAPbouiCOM.Form myForm)
                try
                    SAPbouiCOM.ChooseFromListCollection oCFLs;
                    SAPbouiCOM.Conditions oCons;
                    SAPbouiCOM.Condition oCon;
                    oCFLs = myForm.ChooseFromLists;
                    SAPbouiCOM.ChooseFromList oCFL;
                    SAPbouiCOM.ChooseFromListCreationParams oCFLCreationParams;
                    oCFLCreationParams = (SAPbouiCOM.ChooseFromListCreationParams)SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_ChooseFromListCreationParams);
                    oCFLCreationParams.MultiSelection = false;
                    oCFLCreationParams.ObjectType = "2";
                    oCFLCreationParams.UniqueID = "IFC_CFL";
                    oCFL = oCFLs.Add(oCFLCreationParams);
                    oCons = oCFL.GetConditions();
                    oCon = oCons.Add();
                    oCon.BracketOpenNum = 2;
                    oCon.Alias = "CardType";
                    oCon.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                    oCon.CondVal = "S";
                    oCon.BracketCloseNum = 1;
                    oCon.Relationship = SAPbouiCOM.BoConditionRelationship.cr_AND;
                    oCon = oCons.Add();
                    oCon.BracketOpenNum = 1;
                    oCon.Alias = "GroupCode";
                    oCon.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                    oCon.CondVal = return_GroupNum("Auteur");
                    oCon.Relationship = SAPbouiCOM.BoConditionRelationship.cr_OR;
                    oCon = oCons.Add();
                    oCon.Alias = "GroupCode";
                    oCon.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                    oCon.CondVal = return_GroupNum("Editeur");
                    oCon.Relationship = SAPbouiCOM.BoConditionRelationship.cr_OR;
                    oCon = oCons.Add();
                    oCon.Alias = "GroupCode";
                    oCon.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
                    oCon.CondVal = return_GroupNum("Traducteur");
                    oCon.BracketCloseNum = 2;
                    oCFL.SetConditions(oCons);             
                catch (Exception ex)
    //Catch Error
    2. Affect your CFL to a specific field :
    oEdit = (SAPbouiCOM.EditText)oForm.Items.Item("3").Specific;
                    oEdit.ChooseFromListUID = "IFC_CFL";
                    oEdit.ChooseFromListAlias = "CardCode";
    Hope it's help you
    Regards
    Michael

  • IPhone SDK Download Problems

    I have just made the account and started the long download process for the iPhone SDK. When I download the file and it completes the process, I click on it and it says Disk Image not able to mount. I tried that three more times and it still won't open. Any suggestions?

    Another victim here. Happily started downloading iphone SDK just after purchasing my new MacBook and it always stops at 2.1 GB. And of course it is corrupted.
    For those who are thinking about OS or firewalls, here are my trials:
    1. From my MacBook at home
    2. From my HP laptop at home
    3. From my desktop at home
    4. From my HP laptop at work
    5. From my Ubuntu at home
    6. From my Ubuntu virtual machine at work.
    Do you think it is still a client problem? Or the version on the server is corrupted?

Maybe you are looking for

  • How do i turn off iMessage on my macbook pro

    How do i turn off imessage on my Macbook pro, or at least change the phone number

  • Siri not working in the UK

    I've been using Siri and it works well for most questions, but if I ask it for something about a local business, for example, where is the nearest pizza restaurant, it always replies that Siri is not able to give information for businesses outside th

  • GRC 10 Upgrade: Unable to find a system while creating a request in AC

    Hi All, I am unable to find a system while creating a new request in Access Management. I have created a connector to the backend system  and I tested that by logging into the system remotely. However, the same system is not available for selection f

  • Install schema impacts on DB (BI 10.1.3.3.3)

    Hi.... I tried looking for this detail but couldn't get it in manuals or online....anybody knows what are the impacts of installing scheduler schema on Oracle 10g....? i) what and how many no. of tables it installs...? ii) any other objects created .

  • Problem uploading to istockphoto

    Since I have upgraded to FCP Studio 5.1.2 I have been unable to upload a file to the web. I have tried every coda to no avail. Each time istockphoto says, that they do not reconize jpeg in my file or the file is empty. What am I doing wrong...I expor