Saturday, November 5, 2011

iPhone build error | Codesign failed with exit code 1| object file format invalid or unsuitable

Recently, I have installed Xcode 4.x, this have shown weird errors with existing app , and asked for a lot of change to make it compatible with new complier.
Project timelines are always important, So I reverted back to Xcode 3.2.6

Everything went Okay. But when I tried to apply ( code signing) provisioning certificates to install application into iPhone, Build Failed with error;
Command /usr/bin/codesign failed with exit code 1
with description-
{*}.app object file format invalid or unsuitable


Then I moved to the solution library of developers (stack overflow), As most of the the developers do :)
After spending lot of hours, Saw this answer by emcmanus.

sudo mv /usr/bin/codesign_allocate /usr/bin/codesign_allocate_old
sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate /usr/bin


Tried first command, Blindly..
My terminal CLI answered : No such file or directory!

Then, I Explored /usr/bin folder, and observed yes! It was not there. (there is nothing to keep as back up , after renaming it. Symlinking is the ultimate goal )
I run "sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate /usr/bin"
to create symlink.
and YES! symlink did the trick...


Excellent... Hope this will do the trick for, who is in this trap :)

Thursday, October 20, 2011

iPhone | code crash : Mutated Collection during fast enumeration

If you are going to use , fast enumeration in your objective C code?
for (id {object} in {collection}) {...}" )

You shall not be able to modify the collection (add or remove) during enumeration.
Because, thread will have a lock on the resources being used.

for that either go with the :

1) for(NSUInteger i=0 ; i< [ {collection} length];i++){…}
2) Put the add/remove logic in another thread

Hope this helps!

Saturday, October 15, 2011

Shipment Tracker - Package tracking app for US

Shipment Tracker is live on app store :)
Developed this application for Appcandy productions.

http://itunes.apple.com/us/app/shipment-tracker/id471306380?mt=8

Cheers!

iPhone | UIImage

I was reading a blog article "How to use optimized Image in iPhone Development?",

That article suggests, it is best to use “imageWithContentsOfFile” over [UImage imageNamed:@"YOUR_IMAGE_NAME"]; because image name will not flush image out of memory even if it is set to nil.

Correct! it will not flush, But its good to keep that image in cache, Most of the time, application user moves to-and-fro in app ,
So its not a good idea to get it always from main bundle and get it converted everytime!

Sharing the good part of UIImage:

As per apple developer reference guide for UIImage imageNamed method:

+ (UIImage *)imageNamed:(NSString *)name

name
The name of the file. If this is the first time the image is being loaded, the method looks for an image with the specified name in the application’s main bundle.
If a matching image object is not already in the cache, this method loads the image data from the specified file, caches it, and then returns the resulting object.

Return Value
The image object for the specified file, or nil if the method could not find the specified image.

On a device running iOS 4 or later, the behavior is identical if the device’s screen has a scale of 1.0. If the screen has a scale of 2.0, this method first searches for an image file with the same filename with an @2x suffix appended to it. For example, if the file’s name is button, it first searches for button@2x. If it finds a 2x, it loads that image and sets the scale property of the returned UIImage object to 2.0. Otherwise, it loads the unmodified filename and sets the scale property to 1.0.
Special Considerations
On iOS 4 and later, if the file is in PNG format, it is not necessary to specify the .PNG filename extension. Prior to iOS 4, you must specify the filename extension.

Thursday, October 13, 2011

iPhone | Customize the UITableView header and footer view

To Customize the table header and footer view , Just go fo it....


CGRect newFrame = CGRectMake(0.0, 0.0, self.tableView.bounds.size.width, self.myHeaderView.frame.size.height);
self.myHeaderView.backgroundColor = [UIColor clearColor];
self.myHeaderView.frame = newFrame;
self.tableView.tableHeaderView = self.myHeaderView; // note this will override UITableView's 'sectionHeaderHeight' property

// set up the table's footer view based on our UIView 'myFooterView' outlet
newFrame = CGRectMake(0.0, 0.0, self.tableView.bounds.size.width, self.myFooterView.frame.size.height);
self.myFooterView.backgroundColor = [UIColor clearColor];
self.myFooterView.frame = newFrame;
self.tableView.tableFooterView = self.myFooterView; // note this will override UITableView's 'sectionFooterHeight' property

Thursday, August 25, 2011

isNumeric javascript

There is no predefined function to test ,if a value is numeric .
This function helps to check whether a variable's value is numeric or not.


var isNumeric = function(x) {
// returns true if x is numeric and false if it is not.
var RegExp = /^(-)?(\d*)(\.?)(\d*)$/;
return String(x).match(RegExp);
}


Hope this helps!

Thursday, August 18, 2011

PHP date bug | date ends at 2037

While developing an application having backend in PHP ,when I tried to go past the year 2037 the system jumped back to 1970!
This is a known bug in PHP and is a limitation in counter that is 32 bits long,64bit machines are not vulnerable to this.

http://bugs.php.net/bug.php?id=7103

As per forum

The last date/time that is working:
19.01.2038 03:14:07 ( =2147480047 )

The workaround for this issue is to have 64 bit machine/OS, if you are running any unix based machines. Also make sure that the time_t is set to 64bit !

Hope this helps... and save your time.