Sunday, April 25, 2010

Unicode String in iPhone from webserivce

I had been stuck with the problem of receiving the original Japanese text sent by web service. I was receiving the text in English correctly but instead of receiving the Japanese text I was getting some weird symbols.

And the fix was very simple:
Change the encoding type to NSUTF8StringEncoding when you initialize your Return value with the NSData object..

NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&error];

NSString *jsonString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];

Thursday, April 15, 2010

UITextView with border

Yes, you can have your  UITextView with a border and that too with a rounded corner. I was in search of a way to achieve this for over 6 months and could not get it. So did a work around for that, by drawing a view  with lines around and behind the UITextView.

But today I stumbled upon this thread and was able to discover a way to do that.

Any way I will share the code here. If there are any negative implications behind this solution, please share it.

Code:


yourTextView.layer.borderWidth = 1;
yourTextView.layer.cornerRadius = 8; //This is for achieving the rounded corner.
yourTextView.layer.borderColor = [[UIColor grayColor] CGColor];


And don't forget to include the Quartz core framework. 

#import <QuartzCore/QuartzCore.h>

Bye !

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 !!