NSLocale *indiaLocale = [[[NSLocale alloc] initWithLocaleIdentifier:@"en_IN"] autorelease];
double currency = 1000000000.00;
NSNumberFormatter *numberFormatter = [[[NSNumberFormatter alloc] init] autorelease];
[numberFormatter setNumberStyle: NSNumberFormatterCurrencyStyle];
[numberFormatter setLocale:indiaLocale];
NSString *numberAsString = [numberFormatter stringFromNumber:[NSNumber numberWithInt:currency]];
NSString *str2 = [NSString stringWithFormat:@"Converted:%@",numberAsString];
NSLog(@"String:%@",str2);
Monday, August 27, 2012
comma separated numbers
Sunday, August 26, 2012
Concatenate two strings in objective - C
NSString *hello = @"Hello";
NSString *world = @"World";
NSString *helloWorld = [hello stringByAppendingString:world];
Thursday, August 16, 2012
set labels size as per string in iphone
-(float)getHeightByWidth:(NSString*)myString:(UIFont*)mySize:(int)myWidth
{
CGSize boundingSize = CGSizeMake(myWidth, CGFLOAT_MAX);
CGSize requiredSize = [myString sizeWithFont:mySize constrainedToSize:boundingSize lineBreakMode:UILineBreakModeWordWrap];
return requiredSize.height;
}
Remove .DS_Store & git File using Terminal
To Remove .DS_Store File:-
cd <ur path>
find . -name '*.DS_Store' -type f -delete
To Remove Git File:-
cd <ur path>
find . -name '*.git' -type f -delete
Remove .DS store Files from Document Directory
//clean documnt directory
NSString *folderPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSError *error = nil;
NSMutableArray *dirArr = [NSMutableArray arrayWithArray:[[NSFileManager defaultManager] contentsOfDirectoryAtPath:folderPath error:&error]];
[dirArr removeObject:@".DS_Store"];
for (NSString *file in [[NSFileManager defaultManager] contentsOfDirectoryAtPath:folderPath error:&error])
{
[[NSFileManager defaultManager] removeItemAtPath:[folderPath stringByAppendingPathComponent:file] error:&error];
}
Subscribe to:
Posts (Atom)