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

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.