May 17, 2010

(iPHone)How to retrieve value of "Bundle version"

Here is how to retrieve value of "Bundle version" in the project.plist using code.

NSString *version = [[[NSBundle mainBundle] infoDictionary] 
objectForKey:@"CFBundleVersion"];

(Iphone)How to move up an UIAlertView

Here is a trick to move your UIAlertView up on the screen.

UIAlertView * alert = [ [ UIAlertView alloc ] initWithTitle:@"Alert" 
message:@"Alert" 
delegate:self 
cancelButtonTitle:@"OK" 
otherButtonTitles:nil ];

alert.transform = CGAffineTransformTranslate(alert.transform, 
0.0, 100.0);

[ alert show ];

May 10, 2010

(iPhone)How to resolve "resources have been modified" when install an adhoc version

It's pretty weird my client has met this problem when he install an adhoc version on his iPhone. Arial Balkan posted a very useful solution, the idea is transforming the application (file .app) to an .ipa file which is executable in the iTunes.

May 6, 2010

(XCode)How to resolve Error: 155015 (A conflict in the working copy obstructs the current operation)

It happens on a file i updated from SCM, the solution i found is:

- Backup current working file.
- Run svn revert in console.

Mar 19, 2010

(XCode) How to resolve "Warning: Multiple build commands for output file ..."

Just met a weird warning message in XCode which is "Warning: Multiple build commands for output file ..." after deleting a resource file, and i checked the file does not exist in resource folder any more, finally i found the the file did appear in "targets/app name/copy bundle resources/", than i figure out i accidentally pressed "Delete reference" when i delete the file, and that's why the resource file still exist in the "copy bundle resources" folder

Dec 29, 2009

(Objective-c)How to round a number

Here is a solution to round a float number:

NSString *pi = @"3.14159265";
int floatSize = 3;
NSDecimalNumber *numericValue = [NSDecimalNumber decimalNumberWithString:pi];
NSDecimalNumberHandler *roundingStyle = [NSDecimalNumberHandler 
decimalNumberHandlerWithRoundingMode:
NSRoundBankers scale:floatSize raiseOnExactness:NO raiseOnOverflow:NO 
raiseOnUnderflow:NO 
raiseOnDivideByZero:NO];
NSDecimalNumber *roundedNumber = [numericValue 
decimalNumberByRoundingAccordingToBehavior:
roundingStyle];

or

NSString *pi = @"3.14159265";
NSString *roundedNumber = [[NSString alloc] initWithFormat:
@"%.3f",[pi floatValue]];

Result: 3.142

Dec 7, 2009

(Eclipse)How to resolve "Initializing Java Tooling"

Just met an initialization error on Eclipse, the error message is:

'Initializing Java Tooling' has encountered a problem. An internal error occurred during: "Initializing Java Tooling".

It's really annoying, after googling several sites, here is a working solution:

Delete
the following directory: WORKSPACE_HOME/.metadata/.plugins/org.eclipse.core.resources/.project, and restart Eclipse and problem should be solved.