December 30, 2008
QuickConnectiPhone version 1.1 is now available

Download QCiPhone version 1.1 from here.
It includes the installer as well as new example code for the new features. See how to access a SQLite database, either shipped on the device or in the UIWebView object, by making a few simple calls. Start by looking in the mappings.js file and then the functions.js file to see how easy it is to do. The nativeDBAccess example includes a sample.sqlite database file. The browserDBAccess example shows you how to create and populate a SQLite database within the UIWebView without having any database files.
The browserAJAXAccess example is a simplified example that pulls data from the RSS feed for this blog. Again, look in the mappings.js and functions.js files to see how to do this.
If you want to know how the framework pulls all of this off have a look in the com.js file. It handles the communication to the device for everything from database access to debug messages and error logging. If you want to get even deeper you can check out the Objective-C classes that support the JavaScript device calls.
Want to know how the linearization happens? Look in the QuickConnect.js file and search for the dispatchToBCF function. Then check out the DataAccessObject.js and ServerAccessObject.js files.
All of this, in addition to coverage of PhoneGap will be covered in my upcoming book from Pearson Publishing.
As stated above, version 1.1′s new abilities include a full implementation to access any number of SQLite databases shipped with your application from within JavaScript. This uses the same getData, setData API that version 1.0 used to access SQLite databases in the UIWebVeiw with one modification. If you want to get or set data in a ‘native’ database instead of in the UIWebView you use the getNativeData and setNativeData methods. Everything else is exactly the same between the two types of calls.
I have also linearized the asynchronous calls that you make to the device or remote servers using AJAX. This required some changes to the PhoneDataAccessObject, now renamed DataAccessObject, as well as the ServerAccessObject used for AJAX calls.
In other words, now you can make a call to an SQLite database, an AJAX server, or GPS location information, and then make a call to any other piece of functionality and the second call will not happen until the first asynchronous call has completed. This has been one of the most requested feature changes. You no longer need worry about the timing of your asynch calls. String together any number of asynchronous calls and the framework will ensure that they happen linearly.
Another change is that the QueryResult object is used as the data return for both database calls and AJAX calls. Regardless of the type of call the returned objects are the same.
These major changes are what bumped the version number up to 1.1.
December 16, 2008
QuickConnectiPhone 1.0 Release has shipped.

The 1.0 release version of QuickConnectiPhone is now available for download from SourceForge.
(See the 1.5 release announcement on this blog to see what additional features and examples have been added.)
It allows your application, from JavaScript, to:
- Get browser based database access
- Get access to databases shipped with or created by your application
- Get GPS location information
- Get device acceleration information
- Show and use native Date and Date/Time pickers
- Vibrate the device
- Record and playback audio
- Play system sounds such as the notification sound
- Use a prebuilt drag and drop framework to easily make any DOM object draggable
- Use a prebuilt scaling and rotation framework to easily make any DOM object resizable and rotatable.
Examples for all capabilities are included in the Examples directory included in the download.
An installer is included to add QuickConnectiPhone templates to both Xcode and Dashcode to speed your development. It will also install beta versions of QuickConnectMac and QuickConnectPHP as well as file templates for JavaScript and PHP files.
QuickConnectMac allows you to write Mac applications using the same JavaScript framework that you use for iPhone applications. You can use this instead of Adobe Air. Write your application once and compile it for both iPhone and Mac.
The QuickConnectFamily image Copyright Lee Barney 2008. All rights reserved.
October 10, 2008
QuickConnectiPhone release 1.0 coming soon
The 1.0 version of QuickConnectiPhone is soon to be released. It will include a set of code that will allow you to log debugging messages, vibrate the phone, play system sounds, retrieve GPS data, and accept acceleration data as well as record and play audio files.
All of this functionality is available for calling from both Objective-C and JavaScript. I hope to have embedded Google maps as well so you don’t have to exit your application in order to show a map with a pin or multiple pins.
All of this is added to the existing sqlite database access library for both languages and the AJAX wrapper for JavaScript.
A later version will include AJAX calls from Objective-C as well where the result can be consumed in Objective-C or pushed up into a UIWebView.
Example apps from my upcoming book will also be included.
A version without the map inclusion will be available for download October 18th, 2008 from sourceForge.
June 30, 2008
QuickConnectiPhone framework beta 2
A new version of QuickConnectiPhone is now available. It includes the ability to push Core Location and Acceleration information up into the JavaScript running in your UIWebView. It is open-source and free. You can get it from sourceForge. If you checkout my Blogroll to the lower right of this page you will find a link to the site. Or you could go directly here.
As with Beta 1 it allows you to write your application in Dashcode using HTML, JavaScript, and CSS and then install it and run it on your device. You application will then run without any network connections of any type.
It also lets you store persistent data in SQLite using the new JavaScript API to SQLite. An easy to use wrapper is provided for you within the framework. If you do choose to get data from a web server the framework provides you with an easy to use wrapper for AJAX calls that has the same API as the SQLite wrapper.
Since you are writting your application to run inside of the UIWebView can also use the new CSS transitions, animations, etc. it makes available.
Give it a try and give me some feedback.
May 23, 2008
UIWebView Example Code
The information and source code covered in this posting has been expanded on and is included in a downloadable framework called QuickConnectiPhone. Take a look at this posting about version 1.5 to learn more more.
There is also a development roadmap
It appears that a great need exists for a straight forward example of how to use the UIWebView class. The purpose of this example is to show how to use it from within a class that can be initialized by an application delegate class. I have included both the header and source file code so that you can see how this can be done. The complete source for these files as well as additional code and helps can be found at the QuickConnect site. Go to the downloads section and grab the QuickConnectiPhone framework.
If you wish to have your view scale in response to pinch gestures you will need to uncomment the
//aWebView.scalesPageToFit = YES;
line.
This class also is listening to acceleration events and making a call to a javascript function which you would need to write when an acceleration event occurs. I hope this is helpful. I am working on some QuickConnectiPhone documentation right now and hope to have an introduction video available soon.
To see a quick discription of the QuickConnectiPhone framework see this post.
The header file:
/*
Copyright 2007 Lee S. Barney
This file is part of QuickConnectiPhoneHybrid.
QuickConnectiPhoneHybrid is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QuickConnectiPhoneHybrid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with QuickConnectiPhoneHybrid. If not, see .
*/
#import
#define kAccelerometerFrequency .001 //Hz
@interface BrowserViewController : UIViewController {
UIWebView *webView;
}
@property (nonatomic, retain) UIWebView *webView;
@end
The class file:
/*
Copyright 2007 Lee S. Barney
This file is part of QuickConnectiPhoneHybrid.
QuickConnectiPhoneHybrid is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QuickConnectiPhoneHybrid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with QuickConnectiPhoneHybrid. If not, see .
*/
#import "BrowserViewController.h"
@implementation BrowserViewController
@synthesize webView;
- (id)init
{
/*
if (self = [super init]) {
}
*/
return self;
}
- (void)loadView
{
NSLog(@"loading view");
// the base view for this view controller
UIView *contentView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
contentView.backgroundColor = [UIColor blueColor];
// important for view orientation rotation
contentView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
self.view = contentView;
self.view.autoresizesSubviews = YES;
//create a frame that will be used to size and place the web view
CGRect webFrame = [[UIScreen mainScreen] applicationFrame];
webFrame.origin.y -= 20.0; // shift the display up so that it covers the default open space from the content view
UIWebView *aWebView = [[UIWebView alloc] initWithFrame:webFrame];
self.webView = aWebView;
//aWebView.scalesPageToFit = YES;
aWebView.autoresizesSubviews = YES;
aWebView.autoresizingMask=(UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth);
//set the web view and acceleration delagates for the web view to be itself
[aWebView setDelegate:self];
//determine the path the to the index.html file in the Resources directory
NSString *filePathString = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"];
//build the URL and the request for the index.html file
NSURL *aURL = [NSURL fileURLWithPath:filePathString];
NSURLRequest *aRequest = [NSURLRequest requestWithURL:aURL];
//load the index.html file into the web view.
[aWebView loadRequest:aRequest];
//add the web view to the content view
[contentView addSubview:webView];
[aWebView release];
[contentView release];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations.
return YES;
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
if(fromInterfaceOrientation == UIInterfaceOrientationPortrait){
NSString* result = [webView stringByEvaluatingJavaScriptFromString:@"rotate(0)"];
//NSString a = *result;
NSLog(result);
}
else{
[webView stringByEvaluatingJavaScriptFromString:@"rotate(1)"];
}
//[self.webView sizeToFit];
//CGRect curBounds = [[UIScreen mainScreen] bounds];
//[self.webView setBounds:self.origViewRectangle];
//[[UIScreen mainScreen] bounds]]
//NSLog(@"orienting");
}
- (void) accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration
{
NSString* javaScriptCall = [NSString stringWithFormat:@"accelerate(%f, %f, %f)", acceleration.x, acceleration.y, acceleration.z];
[webView stringByEvaluatingJavaScriptFromString:javaScriptCall];
//Use a basic low-pass filter to only keep the gravity in the accelerometer values
//_accelerometer[0] = acceleration.x * kFilteringFactor + _accelerometer[0] * (1.0 - kFilteringFactor);
//_accelerometer[1] = acceleration.y * kFilteringFactor + _accelerometer[1] * (1.0 - kFilteringFactor);
//_accelerometer[2] = acceleration.z * kFilteringFactor + _accelerometer[2] * (1.0 - kFilteringFactor);
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview.
// Release anything that's not essential, such as cached data.
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
NSLog(@"An error happened during load");
}
- (void)webViewDidStartLoad:(UIWebView *)webView{
NSLog(@"loading started");
}
- (void)webViewDidFinishLoad:(UIWebView *)webView{
NSLog(@"finished loading");
}
- (void)dealloc
{
[super dealloc];
}
@end