Sunday, April 11, 2010

j2me App Development in Mac OS X

Hi Friends,

Those who are in search of an SDK to develop j2me apps in Mac can get the SDK from this Location. And it provides you with a IDE and an emulator. And unlike palm SDK installation, or Blackberry Installation, you don't have any work with Terminal App. And thanks for Sun Microsystem's effort.

And newbies can check this page to have a overview of j2me Application development, CDLC, MIDP, configuration, profiles and packages.

Thursday, April 8, 2010

iPhone Web App: Accessing Webservice with user name and password





Hi Friends,

I was in to development of a Web App for iPhone and after the development got over we had to deploy it in a server. We deployed it. And then the game started.

Our Application internally accessed a webservice from a server which has to be authenticated with the user name and password. And we thought everything would go fine. We tested it in Safari, Chrome and it did work as expected but with a huge delay in displaying the data. Finally we tried in iPhone Safari. And to our frustration, it thrown us unauthorized (401) message. So we tried setting user name and password in open() of xmlHttp object but to no avail in iPhone safari.

Then I tried to setting Authorization Request header  and it threw me a message like "Unsafe Header is set". So  Finally after a period of over 3 days struggle I stumble upon this thread where a ratranch had suggested the solution, where we had to format our URL in the following manner:

http://username:password@your_server_address_and_your_function

Then I tried this option and for heavens sake it worked and I became a relieved man. :)

And to me it seems that this problem is specific to iPhone Safari. I still have not tested it in Android, would test it in Android Browser and update sooner.

Hope this would help some one in search of this solution in web.

Monday, April 5, 2010

iPhone :Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'This NSPersistentStoreCoordinator has no persistent stores. It cannot perform a save operation.

This error when thrown while working on Core Data can make you go insane  ;) .So one situation under which you may encounter this error is that you might have done the following:

1. Added, or deleted or in general modified your Data Model.

2. Then you must have tried to run your application as usual.


You Should try doing  the following and it did helped me.

1. Remove your sqlite file, if you have included any in your project.

2. Delete the entire application from Simulator. You can be more confident if you go the Folder in Library -> Application Support -> iPhone Simulator and delete the Application for the Version of Simulator you are checking.

3. Clean your Targets and Rebuild your Project and run again.

And thats done !!

Tuesday, March 16, 2010

Count No of occurrences of a String or a character

Hi Friends,

I was in a search of a function that would give the number of occurrences of a character or a string in another string and finally I landed in the following solution. If you have any other way to achieve it, please share it.

+ (NSInteger)occurrencesOf:(NSString *)str InString:(NSString *)mainString
{

return [[mainString componentsSeparatedByString:str] count];

}

Thank you.

Friday, March 12, 2010

iPhone OS 4.0 Multitasking

Hi Friends,
This is a good news for iPhone and future iPad users, if it is true as reported in AppleInsider. And as reported this move would silence the critics who always take a dig at apple for not providing the Multitasking. And the main thing to watch out is how is going to achieve it without compromising on battery life.

Lets wait and see whats happening!!

Thursday, March 4, 2010

Rename project File and Target Name in XCode

Hi Friends,

This post is going to help you to change the name of your Project in XCode. And follow the steps given below to achieve the same.

1. Make a copy of your project Folder and delete the build folder if there is one.
2. Rename it to the name you wish to have.
3. Change the name of the .xcodeproj file to the name you wish to have.
4. Change the name of the .pch file.

Now it seems to be fine and when you run you will be blocked by the following error:
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1

So lets get to the fifth step.
5. Go to the Targets. Right click on your Target Name and click Get Info.
6. Now go to the Build tab and find the GCC_PREFIX_HEADER in the User-Defined section and you will find the name of the .pch file that you have just renamed and voila.

For renaming the Target, just change the "Bundle display name" in your <project-Name>-info.plist file. And your done...

Monday, March 1, 2010

Palm WebOS- Web Service and Persistent Storage

Hi Friends,

This article will take you through the ways of handling Web Service and Persistent Storage in Palm Web OS.

First let us look at Web Service.

Web Service

1. We can access webservice using two means.
a. Prototype Javascript Framework (Ajax.Request)
b. Native javascript (XMLHTTPRequest)
2. Exchange data can be of any form (JSON, XML, or any of your own format)
3. Currently only asynchronous operations are supported using XMLHTTPRequest, done to preserve UI responsiveness. (I have not checked with the Ajax.Request. If someone has verified it, please share them)
4.Use Prototype Javascript Framework if you don't wish to control every operation yourself and the framework will take care of everything.
5. use Native Javascript if you wanted more control over your code.

Processing JSON:


1. Two ways:
a. eval()- best to avoid, only if source is trusted.
b. JSON parser- faster, never allow malicious script to get executed.

Processing XML:

1. use either DOM or a SAX parser.

Now lets turn towards, Persistent Storage:

Memory is partitioned as three segments:

1. root- for the OS and apps that come by default like calendar, Browser.
2. var -meant for third party Applications, that we are wiling to develop.
3. Media-media partition are visible on the USB volume( Available in your computer, when you plug-in your Palm based phone- pre or pixi).

Three ways to store data:

1. Cookie
2. Depot
3. HTML5

All three forms of data are tied to an application. So, they will be deleted, if you delete your application from the device.

Cookie:

1. Data stored as a key-value pair.
2. It has nothing to do with the Web browser cookie, other than storing data.
3. Maximum of 4KB of data.
4. Can be used to store preferences, simple settings.

Depot:

1. Can store up to 1 MB of data.
2. Size can be extended by using a keyword ext,while creating database.
3. Data stored as Key-value pair.
4. Normal way of creating DB:
var db = new Mojo.Depot({name:”demo”}, onSuccess, onFailure);
5. For extended storage:
var db = new Mojo.Depot({name:”ext:demo”}, onSuccess, onFailure);

HTML 5 database

1. It is a structured database, unlike the first two.
2. Normal way of creating the DB:
this. db = openDatabase("myDB", 1, "My DB", 10000);
3. To store data in Media partition, use
this. db = openDatabase("ext:myDB", 1, "My DB", 10000);


Depot and HTML5 DB operations are asynchronous, unlike the Cookies.

And thats all for this article. Thank you.