February 7, 2009

QuickConnectiPhone 1.1.3 now available

Posted in iPhone development tagged , , , , , , , , , , , , , , , , , , , at 11:37 pm by tetontech

QCiPhone version 1.1.3 includes the following changes.

  1. Example applications updated to 1.1.3
  2. apostrophes in the data of native databases now handled correctly.
  3. a stopBounce() function added in the JavaScript.  It stops the UIWebView from bouncing when the interface fits in the view.  Thanks
    to Aarpn for the initial code.  I’ll work on getting it to be more
    flexible.
  4. A Default.png file added so you can replace it with your own.

If you are interested, QCiPhone 1.5 Beta 1 is now available.  The announcement is here

Advertisements

46 Comments »

  1. Sam said,

    I tried version 1.1.2 and 1.1.3 also. Here are my comments:

    – Can’t covert Dashcode to Xcode App. It doesn’t work. It will be appreciated that author can provide clear cut directions on this. When I convert Dashcode to Xcode app a black screen is obtained. How this can be debugged?

    – Also, in 1.1.3, there is no blank template provided. It always start with the default template.

    I am more than willing to help to test these applications if author is willing to take this help.

    • tetontech said,

      Sam,

      To debug your black screen issue make sure you are following the steps listed in the wiki.

      If that doesn’t solve the problem email me your project at the address I provided in our private emails and I will take a look at it. Every time I have seen this before it has been because one or more files were not copied over or were not copied to the build during the build process.

      The template isn’t blank as you noted. I added a line to the “congratulations” page to help users know to replace the Default.png file with their splash screen.

      Do you want me to remove it from the Dashcode template?

  2. sam said,

    tetontech-
    A few questions on this release:
    – I can’t find the mapOnLaunch xCode project. The folder only contains the build folder.
    – The state saving project doesn’t appear to be working correctly. I type a word and press save. The word disappears and I’m told that it has been saved. However, when I relaunch, it is not there. Any suggestions?
    – Thanks for including the Default.png functionality; however, I’m not noticing much of a difference (i.e. App loads with default.png, white screen, html loads). Am I doing something wrong?

    Thanks again.
    -Sam

    • tetontech said,

      Sam,

      It looks like there was some problem with zipping up the release. I’ll re-do it and update the 1.1.3 release.

      The problem with the white screen is that the UIWebView will not render any of the HTML until is it made visible. I’ll keep trying to find a way around this but for now it looks like we’re stuck with the white flash.

  3. tetontech said,

    Sam,

    I have re-zipped and re-published the 1.1.3 release. It should be good now.

  4. Sam said,

    Thanks a lot. I will try this in next two/three days and let you know. I am on the official trip for next two days.

  5. Sam said,

    Yes, I tested this just now. I was able to convert Dashcode widget to Xcode App.
    It will be good if you can provide the default empty template at the start rather than splash screen. Splash example will be great for the examples. Now, to actual project design and implementation.

  6. craig said,

    I’m trying to build the application on my iPhone and am getting the error.

    “0xE900003A” Which apple has said represents a mismatch between your App ID in your provisioning profile and your Bundle Identifier in your Info.list.

    Any specific instructions on getting this to run? thanks in advance.

    • tetontech said,

      Craig,

      I assume that you have gone to the iPhone dev site, registered, entered the program portal and got your certificates, built your team, registered your device ID, etc.

      If this is the case you need to go into the Info.plist file in the Resources group and make a modification

      There is a line that looks like this:
      com.yourcompany.${PRODUCT_NAME:identifier}

      You will need to replace the com.yourcompany portion of the string with the string you used when creating your application id’s. I work for BYU-Idaho and so I could have used the string edu.byui.* when creating my application id’s. If so, I would change the line above to look like the line below.

      edu.byui.${PRODUCT_NAME:identifier}

      I hope this helps.

      Lee

  7. Sam said,

    tetontech–
    This might be a possibility for the Default.png issue. Perhaps make a frame that loads the Default.png and on top of the loading content. Make a delay of 3 seconds before the frame becomes hidden. I drew out a diagram to show what I’m trying to explain.

    • tetontech said,

      Sam,

      What you are proposing is the idea I have been playing with. It appears from Apple’s documentation that the UIWebView doesn’t actually render its’ content until it is viewable. I’m exploring if it is possible to somehow force it to render.

      Lee

  8. Craig said,

    Thanks Lee, that worked perfectly. Keep up the good work, it’s making application dev for iPhone and Android fun and easy for us all.

  9. Gil said,

    I don’t think I received the NativeDB examples in the download. I am trying to initialize an array of data from the sqlite database. Is this possible?

    • tetontech said,

      Is the NativeDBAccess directory in the Examples directory empty? I had someone else say that only the build directory was in the download. I re-compressed and refreshed the download about a week ago. The example was there when I downloaded it today. Try downloading it again.

      It is absolutely possible to initialize an array from data in an sqlite database shipped with an application.

  10. Gil said,

    Thanks for the reply. As for the Examples I am only seeing the build directory and redownloaded last night. I am still not seeing.
    I figured out that I didn’t include all of the javascript files in my index.html which was why it wasn’t working. I am still not getting my data in the array but I suspect it’s another problem. Is there an easy way to debug the Javascript layer besides alerts? I can’t set a breakpoint in Xcode in the Javascript. What is happening is that I have two methods in my mapping, the first grabs the data the second sets to the array but the 2nd isn’t being called.
    Is there a better place to post this? (Forum or something).

    Thanks,

    Gil

    • tetontech said,

      I’ll refresh the download again.

  11. Gil said,

    OK I think I figured it out. One suggestion to anyone else reading this is to use try/catch blocks as much as possible. Javascript just stops so you can’t necessarily see what the problems are. The catch though allows the processing to continue and you can see the error.

    • tetontech said,

      I use the framework’s debug function for debug messages as well as try-catch blocks. In the catch I use the framework’s logError function and pass it the error generated for the catch. This seems to get me what I need.

    • tetontech said,

      Here is the type of output you get when you use the logError function.

      JavaScriptMessage: ERROR: TypeError: Value undefined (result of expression anADHOCServerAccessObject.sendKeyAndParametersToServiceTagged) is not object. main.js line: 38

      Here is an example of using it from the Bonjour networking stuff I am working on right now.

      function load()
      {
      try{
      determineReachability();
      dashcode.setupParts();
      }catch(err){
      logError(err);
      }
      }

  12. Gil said,

    I’m still not seeing the change. I am downloading from SourceForge but maybe you’ve updated another place?
    One other question is about doing updates. My application is very database intensive. (And I think the system is caching the database too but I can’t figure out how/where using simulator.) In any case, I will at some point want to do updates of the data. I am guessing I would send a new file and then run as updates? Or do I send a new sqlite file and just have the code read that in?

    Any suggestions?
    Thanks,

  13. Gil said,

    I did find out some information about doing this type of app. I’m happy to write something for the WIKI as well. Here is one answer about the database:

    http://stackoverflow.com/questions/554009/deploying-sqlite-db-on-iphone-app-upgrade/557784

    Basically, what one person wrote is that if the database is in the application bundle, the update process should update the data. If the data is in a database on the iPhone it needs to be updated. I am thinking if you just want to update specific rows is to read in a file using Javascript XMLHTTPREQUEST and do update statements to the rows in question. I haven’t decided the best way for myself with regards to this.

    In any case, thank you for your help thus far and the terrific framework!! It really makes doing this much easier than writing things from scratch.

    • tetontech said,

      Gil,

      You should be able to use the setNativeData method of the DataAccessObject to modify any tables in a database you have included in your resources bundle. It takes two paramters.

      The first is an SQL statement. If you use the ? place holders the framework creates and uses a prepared statement for you. The second parameter is an array of values that are bound to the place holders.

      I’ll create a new example of how to do this. Hopefully tonight depending on how much progress I make on the Bonjour networking today.

      If you declare the database to be modifiable the framework will move it into the documents directory for your application if it doesn’t already exist there.

  14. Gil said,

    Thanks. I think I figured that out with the setNativeData. My particular case is relatively simple because I know what needs to be updated and replaced.

    Is it possible to do something like the .read function to read a series of statements in at once? The other option is that I replace the entire document each time the user does an update. What I don’t know is how to do that. Basically, I want to allow the user to go to my website and get the new data from within the application. I can grab a text file to do the inserts/updates but can I grab an entire database and replace the existing one on the iPhone? I suspect not.

    • tetontech said,

      Gil,

      Getting the .sqlite file via AJAX could be a problem. They are not text files and so you would have to do a binhex conversion of the database file on both the server and the client side. Replacing the database would also mean that any changes already added would be lost.

      It would be possible to add capability on the Objective-C side of the framework to retrieve the file as binary and place it in the applications documents directory. I haven’t had any requests for this behavior and so haven’t added it to the shipping framework. If I get enough requests I will add it.

      As a workaround for the time being I would suggest that a file of SQL commands be retrieved from the server and the setNativeData method used to execute them.

  15. Sam said,

    Hello again,
    I was wondering if there was a way to launch the App Store from within the UIWebView. Nothing happens when the link is clicked.
    -Sam

    • tetontech said,

      It certainly can be done with a minor modification to the Objective-C code.

      The original idea for the framework was to keep the user in the application
      and not let them select a link that would load some other page from the
      internet since the application behavior would suddenly change. Be cause of
      this the original code does not allow any page but the index.html page to
      be loaded.

      If you want to change this do the following realizing that if the url starts with http that the content may load inside the UIWebView instead of launching the app store application.

      This change also opens a potential security leak since any web page is now accessible from any link you add to your application.

      Open the QuickConnectViewController.m file and change lines 285 – 293 to
      look like the code below and your pages should load. It still restricts
      loading out of application pages (for security as well as usability
      reasons).
      I hope this helps,
      Lee
      /*
      * Only load the page if it is the initial index.html file
      */
      NSRange aSubStringRange = [url rangeOfString:@”index.html”];
      NSRange httpRange = [url rangeOfString:@”http:”];
      if(aSubStringRange.length != 0 || httpRange.length != 0){
      return YES;
      }

      return NO;

  16. Gil said,

    Hi Lee,

    Thanks for the assistance. I think you are correct about doing the updates through grabbing a SQL file. I have it sort of working and running into issues probably in the file itself. I have two more questions that I wasn’t sure about.

    1. Is there a way in the UI to create a fixed navigation layer using Javascript? I am guessing not and I am guessing that the MainWindow.xib needs to be modified to add a UINavigation or UITabBar to the QuickController and then program separately.

    2. What is the object called that allows you to superimpose the alphabet on the left side of a long list view. I would like to add that but don’t know what it is called and can’t find anything about it in the docs. Is there a way to do that function in a webapp? Again I’m guessing no.

    Thanks,

    Gil

    • tetontech said,

      Gil,

      The answer to your first question is yes. You can do this in HTML, CSS, and JavaScript. I have put a blog posting up about it. the URL is here.
      https://tetontech.wordpress.com/2009/02/21/navigation-bars-in-hybrid-applications/

      The answer to your second question is also yes. If you built an unordered list with the alphabet listed in it and the CSS to make it look like the listing in the Contacts app you could follow the same pattern explained in the posting to place it outside of the views in the stack layout or browser Dashcode part. You could add onclick listeners for each of the list items you generate to scroll the page to the location desired. If you don’t want to use JavaScript to do the scrolling, you might be able to put anchor tags in the display and go directly to them by putting links in the list items.

      Lee

  17. Gil said,

    That is awesome! Thank you so much. I can’t wait to try it out.

    Oh, for others as well. The other idea I have about the alphabet listing is to add a search box at the top that finds the item in the list as it is being typed. This function is similar to the Search in the App store.

  18. tetontech said,

    Gil,

    I have updated 1.1.3 again to try and get the native data access example to be included in the examples. It shows up on my machine after I download it. It should also be in the new 1.5 Beta distribution.

    Lee

  19. Gil said,

    Lee,

    Thanks. I got it this time. I’ll take a closer look at it. I appreciate the help.

    Gil

  20. sam said,

    Hi again.
    I’m still having trouble opening the app store. I can get other websites to load in the UIWebView, but the app store links refuse to work. Nothing loads in its place. I made the changes you suggested, however.
    Any ideas?

    • tetontech said,

      Sam,

      I’ll have to play with this and see if it is a limitation of the UIWebView.

  21. Gil said,

    Hi Lee,

    I am getting this in the debugger. As a little history, it occurs after I do an XMLHTTPRequest to grab a file that contains about 1200 SQL update statements. (An initial load of data for subscribers). I don’t get this if I pre-load the data from the commandline. I get out of the loop loading the data but not sure why this is happening. Should I load the SQL file all at once? (Can I do that?)

    TIA,
    Gil

    Loading program into debugger…
    GNU gdb 6.3.50-20050815 (Apple version gdb-962) (Sat Jul 26 08:14:40 UTC 2008)
    Copyright 2004 Free Software Foundation, Inc.
    GDB is free software, covered by the GNU General Public License, and you are
    welcome to change it and/or distribute copies of it under certain conditions.
    Type “show copying” to see the conditions.
    There is absolutely no warranty for GDB. Type “show warranty” for details.
    This GDB was configured as “i386-apple-darwin”.warning: Unable to read symbols for “/System/Library/Frameworks/UIKit.framework/UIKit” (file not found).
    warning: Unable to read symbols from “UIKit” (not yet mapped into memory).
    warning: Unable to read symbols for “/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics” (file not found).
    warning: Unable to read symbols from “CoreGraphics” (not yet mapped into memory).
    warning: Unable to read symbols for “/System/Library/Frameworks/CoreLocation.framework/Versions/A/CoreLocation” (file not found).
    warning: Unable to read symbols from “CoreLocation” (not yet mapped into memory).
    Program loaded.
    sharedlibrary apply-load-rules all
    Attaching to program: `/Users/g/Library/Application Support/iPhone Simulator/User/Applications/D9DAC50E-EF60-4E9B-B28F-1E79709E744F/myApp.app/myApp’, process 36747.

    • tetontech said,

      Gil,

      Go into the pch file of your application (found in Other Sources) and uncomment the #define Debug line. Run your application again and show me the lines that appear right before the standard message in your last comment. This may help me figure out what is going on.

      Another thing that would help me figure out what is going on would be to break the SQL file up into two files and make two calls to get and handle them.

      Lee

  22. Gil said,

    Hi Lee,

    I made the change and received below. It appears that fewer lines are getting calculated as I am only getting the first three lines. I changed the file from drop/create to just delete and ran into an error as well. Could this error be happening because the database is read-only? I have it in my build in my targets directory (native). Reads work great and I think it is actually losing data because if I turn off the update and re-run it doesn’t return any rows.

    2009-02-25 12:29:38.738 myaApp[87386:20b] dispatching command setData
    2009-02-25 12:29:38.740 myaApp[87386:20b] found (
    SendDBResultVCO
    ) for key setData
    2009-02-25 12:29:38.741 myaApp[87386:20b] num command objects 1
    2009-02-25 12:29:38.742 myaApp[87386:20b] before
    2009-02-25 12:29:38.745 myaApp[87386:20b] CO: SendDBResultVCO
    2009-02-25 12:29:38.745 myaApp[87386:20b] params (
    ,
    “myaApp.sqlite”,
    “delete from dx_tx_overview_data;”,
    (
    ),
    (
    updateData,
    1,
    (
    ),

    ),

    )
    2009-02-25 12:29:38.748 myaApp[87386:20b] daresult:
    2009-02-25 12:29:38.749 myaApp[87386:20b] range: 5, 1
    2009-02-25 12:29:38.760 myaApp[87386:20b] result: {“data”:[],”errorMessage”:”not an error”,”numRowsFetched”:0,”insertedID”:0,”numResultFields”:0,”fieldNames”:(null),”rowsAffected”:0}
    2009-02-25 12:29:38.761 myaApp[87386:20b] Result string: {“data”:[],”errorMessage”:”not an error”,”numRowsFetched”:0,”insertedID”:0,”numResultFields”:0,”fieldNames”:(null),”rowsAffected”:0}
    2009-02-25 12:29:38.764 myaApp[87386:20b] result added
    2009-02-25 12:29:38.765 myaApp[87386:20b] returning results from SENDDBRESULTVCO: (
    “{\”data\”:[],\”errorMessage\”:\”not an error\”,\”numRowsFetched\”:0,\”insertedID\”:0,\”numResultFields\”:0,\”fieldNames\”:(null),\”rowsAffected\”:0}”,
    (
    updateData,
    1,
    (
    ),

    )
    )
    2009-02-25 12:29:38.774 myaApp[87386:20b] about to send JSON: [“{\”data\”:[],\”errorMessage\”:\”not an error\”,\”numRowsFetched\”:0,\”insertedID\”:0,\”numResultFields\”:0,\”fieldNames\”:(null),\”rowsAffected\”:0}”,[“updateData”,1,[],null]]
    2009-02-25 12:29:38.775 myaApp[87386:20b] handleRequestCompletionFromNative(‘[“{\”data\”:[],\”errorMessage\”:\”not an error\”,\”numRowsFetched\”:0,\”insertedID\”:0,\”numResultFields\”:0,\”fieldNames\”:(null),\”rowsAffected\”:0}”,[“updateData”,1,[],null]]’)
    2009-02-25 12:29:38.776 myaApp[87386:20b] jsResult:
    2009-02-25 12:29:38.777 myaApp[87386:20b] result:
    2009-02-25 12:29:38.777 myaApp[87386:20b] returning (null) from dispatch
    2009-02-25 12:29:38.778 myaApp[87386:20b] Done handling request
    2009-02-25 12:29:38.805 myaApp[87386:20b] should start loading

    [Session started at 2009-02-25 12:29:38 -0800.]
    Loading program into debugger…
    GNU gdb 6.3.50-20050815 (Apple version gdb-962) (Sat Jul 26 08:14:40 UTC 2008)
    Copyright 2004 Free Software Foundation, Inc.
    GDB is free software, covered by the GNU General Public License, and you are
    welcome to change it and/or distribute copies of it under certain conditions.
    Type “show copying” to see the conditions.
    There is absolutely no warranty for GDB. Type “show warranty” for details.
    This GDB was configured as “i386-apple-darwin”.warning: Unable to read symbols for “/System/Library/Frameworks/UIKit.framework/UIKit” (file not found).
    warning: Unable to read symbols from “UIKit” (not yet mapped into memory).
    warning: Unable to read symbols for “/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics” (file not found).
    warning: Unable to read symbols from “CoreGraphics” (not yet mapped into memory).
    warning: Unable to read symbols for “/System/Library/Frameworks/CoreLocation.framework/Versions/A/CoreLocation” (file not found).
    warning: Unable to read symbols from “CoreLocation” (not yet mapped into memory).
    Program loaded.
    sharedlibrary apply-load-rules all
    Attaching to program: `~Library/Application Support/iPhone Simulator/User/Applications/3810298B-488D-45B5-9119-2DBB221CFCF0/myaApp.app/myaApp’, process 87386.
    (gdb)

    Thanks,

    Gil

  23. Gil said,

    One more thing:

    Here’s how I create my database
    sampleDatabase = new DataAccessObject(“data.sqlite”,null, null, null, true);

  24. sam said,

    I found this as a possible fix for the App Store issue:
    http://www.iphonedevsdk.com/forum/iphone-sdk-development/9424-external-links-uiwebview.html

    I don’t know how to implement it though, I was hoping you might.

  25. Gil said,

    Hi Lee,

    Any ideas about my database issue? Just to let you know, if I take this file and load into sqlite from the commandline there are no problems.

    Thanks,

    Gil

  26. Gil said,

    Hi Lee,

    I had some ampersands in my data that were not escaped that was causing the termination exception. (I didn’t get this running the script directly to Sqlite.

    Now I am getting an exception JavaScriptMessage: ERROR: SyntaxError: JSON.parse json2.js line: 477

    So here’s my question that I think is easy for you to answer (I hope). How should single and double quotes be escaped? Should they be?

    And if I have a single quote in the content of my data (to be inserted such as “cat’s” for example which is escaped as cat”s) how should that be escaped?

    Thanks,

    Gil

    • tetontech said,

      Gil,

      Sorry for being out of touch recently. It has been very busy around here.

      To correctly escape the apostrophe’s in your data replace lines 64 and 65 in the SendDBResultsVCO.m file with these three lines from the 1.5 beta.

      [generator release];
      dataString = [dataString stringByReplacingOccurrencesOfString:@”‘” withString:@”\\'”];
      NSString *jsString = [[NSString alloc] initWithFormat:@”handleRequestCompletionFromNative(‘%@’)”, dataString];

      I haven’t tried it yet but I think ampersands would be done like this.

      dataString = [dataString stringByReplacingOccurrencesOfString:@”&” withString:@”\\&”];

      right after the apostrophe replacement line.

      Let me know it the ampersand line works and I will add it to 1.5 beta 2.

  27. Gil said,

    Hi,

    Sorry for my delay. I was working on paid work this week 🙂 So I must have already done that as that’s what I am seeing in my code. Here’s what I had:

    [generator release];
    dataString = [dataString stringByReplacingOccurrencesOfString:@”‘” withString:@”\\'”];
    dataString = [dataString stringByReplacingOccurrencesOfString:@”&” withString:@”\\&”];

    NSString *jsString = [[NSString alloc] initWithFormat:@”handleRequestCompletionFromNative(‘%@’)”, dataString];

    In any case, I am getting the JSON error not every time (last time I ran I only saw one) and the data is loading. So something is working.

    I’ll try with Beta2 though.

    Gil

  28. Gil said,

    So I just realized that I was running a different method than I remembered so it isn’t working now. Not sure why. It’s only throwing the error once because I only have one query. It’s a select so it’s sort of strange.

  29. Gil said,

    Sorry for all of the messages. I must have had a bad build on my iPhone Simulator. Once clearing it and reinstalling lead to it working with no errors (for now)!

    • tetontech said,

      I’m glad you’ve got it working.

  30. […] is now included in a framework called QuickConnectiPhone.  If you want to know more have a look at this post as well as others in this […]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: