Thursday, June 3, 2010

currently selected language - iPhone

A titbit now. It is easy to find currently selected language in the iPhone. we can use  NSLocale class to get that. This will give you the Language prefix..(for English - en)

NSString *preferredLang = 
[[NSLocalepreferredLanguages] objectAtIndex:0];


Another way to get the language is by  using the following lines:








NSUserDefaults* defs =
 [NSUserDefaults standardUserDefaults];

NSArray* languages = 
[defs objectForKey:@"AppleLanguages"];

NSString* preferredLang = 


[languages objectAtIndex:0];



Tuesday, June 1, 2010

How does Mozilla makes money?

This question was passing by my mind when ever I open my Firefox browser(very rarely I do it). But I usually get in to the tasks that I was after and forget the question.

But this time I thought, I should not give up and searched in Google. So,

How does Mozilla makes money?

Mozilla Foundation has a deal with the Google, the Internet giant, under which Firefox Browser provides Google as the default search Engine and has its default search page hosted by Google, thereby contributing to the revenues of Google. 

For this Google pays Mozilla foundation. Another source of income is Voluntary contributions. So this is the way by which Mozilla Foundation runs....

SOURCE :http://www.zdnet.co.uk/news/desktop-apps/2005/02/28/google-keeping-the-wolf-from-firefox-door-39189475/

http://www.firefoxanswer.com/firefox/795-firefoxanswer.html

Tuesday, May 18, 2010

Memory Leaks named “open_handle_to_dylib_path”, RegisterEmbeddedAudioCodecs() and CPAThreadStart()


Removing memory leaks in the  App  we develop would be an interesting act .(at least for me). And some times those leaks that have no rationale behind their occurrence can be a nightmare. And I went through this nightmare for over one week. I was gifted by the Instruments tool the following leaks in my app.
  • open_handle_to_dylib_path - Responsible library was CoreGraphics.
  • RegisterEmbeddedAudioCodecs() - AudioToolbox- (This occurred twice.)
For me the Instruments directed me to the line
int retVal = UIApplicationMain(argc, argv, nil, nil);
in the main.m file for first leak. I know there was no rationale behind this problem, but was unsure how I am going to prove it.
And the second problem also was of the same shade pointing me to the line
[audioPlayer play];
in my code.
All these time I was testing my app in iPhone Simulator and I got a way to prove these leaks were untrue.
So I tested my app in the iPhone and got cleared of these leaks. And I was very happy until, I saw another leak from the AudioToolbox library named "CPAThreadStart()". I am on my way to fix it. But  a thread running in cocos2d gave me little bit of relief  that  the leak is present in AudioToolbox. So hoping that the leak is within AudioToolbox I am closing this post.

Friday, May 14, 2010

.png images not loaded in iPhone

Sometimes when you may have some images displayed in your iPhone simulator and when you try to deploy it in iPhone the images may not be displayed.
      One reason which may cause this situation is for the sake of having .png images in your app, you might have changed all the other type of images (jpg or any type ) directly through  "Get Info" option. And at this case your image will be displayed in simulator and not in iPhone.

This service is invalid - iPhone

This error that I was presented by Xcode while trying to run my App in iPhone, led me wildly think that my developer certificate has been either revoked or has past its life.
          But after googling found a result which asked me to restart my iPhone and after this I successfully got rid of the "This service is invalid " error message but was faced with another error message "an unknown error occurred". Then I tried by disconnecting the phone from Mac and restarted the phone. 


And this worked and my  app was installed in the phone.

Monday, May 3, 2010

UITableView backgroundColor in iPad


When you try to change the background color of your UITableView in iPad(not in iPhone), you  will be shocked to find the color of your table  not getting changed. So what to do? Just add the following line
[tableView setBackgroundView:nil];
And voila. It seems that right from iPhone 3.2 you will have to set the background view of your TableView.

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];